pso*_*lms 1 javascript firefox
我有一个显示图像的html页面.它应该延迟,更改为视频,然后在视频播放后,更改回图像.这是我正在使用的JavaScript:
<script type="text/javascript">
function playVideo(){
var str='**html of the video object**';
document.open();
document.write(str);
document.close();
}
function backToImage(){
var str='**html of the image**';
document.open();
document.write(str);
document.close();
}
setTimeout("playVideo()",1000);
setTimeout("backToImage()",3000);
</script>
Run Code Online (Sandbox Code Playgroud)
此JavaScript可在Chrome和Safari中使用.它主要在IE中工作(第二次超时不起作用,但我刚刚发现了这一点).它在Firefox中根本不起作用.没有延迟,视频只是开始播放,我从来没有看到图像; 之前或之后.
对此的任何想法都会很棒.
编辑:所以似乎应该责备document.write.改变标题以反映这一点.
如果我的原始问题不清楚,我要找的是用视频替换图像,然后用图像替换视频.这都是在iframe中加载的,所以我需要使用document.write(或类似的东西)来实际更改 html.
document.write页面已经加载后使用有点奇怪.这应该只用于在加载时生成页面.尝试这样的事情:
<html>
<head>
<script type="text/javascript">
function playVideo(){
var str='**html of the video object**';
document.getElementById('video-placeholder').innerHTML = str;
}
function backToImage(){
var str='**html of the image**';
document.getElementById('image-placeholder').innerHTML = str;
}
setTimeout(playVideo, 1000);
setTimeout(backToImage, 3000);
</script>
</head>
<body>
<div id="video-placeholder"></div>
<div id="image-placeholder"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5196 次 |
| 最近记录: |