Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title> http://jsfiddle.net/F35Fw/1/ - jsFiddle demo</title>
- <script type='text/javascript'>//<![CDATA[
- function test(e) {
- var c = (typeof e.which == "number") ? e.which : e.keyCode;
- if (c!=13) {
- return;
- }
- var soundList = [
- 'correct_password.mp3',
- 'wrong_password.mp3' ];
- var ae = document.getElementById('audioplayer');
- if (document.getElementById('password').value == 'pass') {
- ae.setAttribute("src", soundList[0]);
- } else {
- ae.setAttribute("src", soundList[1]);
- }
- ae.play()
- }
- //]]>
- </script>
- </head>
- <body>
- <input type="text" id="password" placeholder="Enter Password (pass)" onkeyup="test(event)" />
- <div id="audiocontainer">
- <audio id="audioplayer"></audio>
- </div>
- <!-- for flash fallback for compatibility with older browser with audio tag support look also here:
- http://stackoverflow.com/questions/17387702/html5-audio-song-only-playing-first-2-in-array
- -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement