Click here to Skip to main content
15,922,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am having a problem with sound playing after perticular interval using javascript,the problem is my code is working fine in firefox but when i run it in IE, page automatically refreshes so if I tries to write something in any textbox, it looses focus on every refresh.
Here's the code I used :

JavaScript
<script type="text/javascript" language="javascript">
function InitSound()
{
    window.setInterval("DHTMLSound('beep.wav');",2000);
}

function DHTMLSound(surl)
{
    document.getElementById("dummyspan").innerHTML = "<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}

InitSound();
</script>
Posted
Updated 16-May-11 22:40pm
v3

1 solution

HTML
<html>
<head>
<script type="text/javascript">
function InitSound()
{
   setTimeout("DHTMLSound('beep.wav')",2000);
}

function DHTMLSound(surl)
{
    document.getElementById("dummyspan").innerHTML = 
    "<embed src="" +surl+ "" hidden="true" autostart="true" loop="false" />";
}
</script>
</head>
<body>
<!-- ALL THE HTML FOR YOUR PAGE FIRST!!! -->
<script type="text/javascript">
     InitSound();
</script>
</body>
</html>




Works and Tested in IE8, IE9 FF 3.5 FF 4.0

-Artificer GM
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900