Javascript and Frame
Javascript and Frame
下面的代码一直显示一个空白页。我尝试了两种不同的方法。似乎要么函数没有被调用,要么帧没有被更新。怎么了?感谢。
<html>
<head>
<script type="text/javascript">
var links = [];
links[0] = "http://www.cbs.com";
links[1] = "http://www.nbc.com";
links[2] = "http://www.cnn.com";
var x = 0;
var delay = 3000;
changeLink();
function changeLink()
{
document.getElementById("report").source = links[x];
// parent.report.location = links[x];
x = x + 1;
if( x > 2) { x = 0;}
setTimeout(function() { changeLink() }, delay);
}
</script>
<title>Report</title>
<body>
<frameset border="0" frameborder="0">
<frame name="report" id="report" src="#" frameborder="0" scrolling="no">
</frameset>
</body>
</head>
</html>
更改此行
document.getElementById("report").source = links[x];
自
document.getElementById("report").src = links[x];
另外不要使用框架集和框架,而是使用 iframe
<iframe name="report" id="report" src="#">
还要在窗口加载事件中添加此changeLink();
方法调用
window.onload = function(){
changeLink();
};
相关文章:
- Selenium WebDriver and JavaScript change
- PHP and Javascript functions
- Javascript Return and if/else
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- TimelineJS and AngularJS
- timeago.js with datatable and PHP
- javascript button ajax and php
- Ajax and Json with Rails
- Combine onload, onresize and onclick
- php布尔值's小写AND大写和数字布尔值'可以接受
- setTimeout and V8
- Jquery post and onclick
- Moment js and IOS
- Rails 3.2 and Paloma gem
- Backbone, TypeScript, and super
- iframe and JavaScript on different pages
- JSON and jQuery Search
- Javascript setTimeout and frame rate
- Javascript and Frame