使用javascript计时器时,页面在IE中刷新 [英] Page getting refreshed in IE when using javascript timer

查看:52
本文介绍了使用javascript计时器时,页面在IE中刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在使用javascript进行间隔间隔播放后出现声音问题,问题是我的代码在firefox中运行正常,但是当我在IE中运行时,页面会自动刷新,因此,如果我尝试在任何文本框中编写内容,则会失去关注每次刷新.
这是我使用的代码:

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 :

<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>

推荐答案

<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>





在IE8,IE9 FF 3.5 FF 4.0中工作并经过测试

-Artificer GM





Works and Tested in IE8, IE9 FF 3.5 FF 4.0

-Artificer GM


这篇关于使用javascript计时器时,页面在IE中刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆