如何为随机图像变化设置时间间隔
我想设置一个间隔,这样它每次都会从这个函数生成一个随机链接:
function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="/documents/templates/bilgiteknolojileri/standalone.swf"
myimages[2]="/documents/templates/bilgiteknolojileri/mobil.swf"
myimages[3]="/documents/templates/bilgiteknolojileri/3b2.swf"
var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<embed wmode="transparent" src="'+myimages[ry]+'" height="253" width="440"></embed>')
}
random_imglink()
但问题是,在我将超时集成到这样的函数中后
random_imglink()
setInterval( "random_imglink()", 2000 );
,2秒后它只显示嵌入对象,我的意思是唯一的页面上显示的东西是嵌入对象,仅此而已......再过 2 秒后,它不会更改该对象......我想要的只是更改嵌入对象内的链接,这样它就不会阻止页面视觉,请帮助我!
i want to put an interval ,so that it will generate each time a random link from this function:
function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="/documents/templates/bilgiteknolojileri/standalone.swf"
myimages[2]="/documents/templates/bilgiteknolojileri/mobil.swf"
myimages[3]="/documents/templates/bilgiteknolojileri/3b2.swf"
var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<embed wmode="transparent" src="'+myimages[ry]+'" height="253" width="440"></embed>')
}
random_imglink()
but the problem is that after i integrate the timeout to a func like this
random_imglink()
setInterval( "random_imglink()", 2000 );
after 2 sec it shows just the embed object, i mean the only thing that displayed on the page is the embed object, thats all.. and after another 2 sec it doesn't change the object... all i want is to change just the link inside the embed object, so that it wont brake the page vision, please help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该在超时时写入嵌入对象,而应该在那里覆盖它。
将嵌入对象直接添加到 HTML 中:
然后在计时器函数中将写入更改为如下所示:
You should not write the embed object in timeout but overwrite it there.
Add the embed object directly into your HTML:
Then in your timer function change the writing to something like this: