使用 javascript 滚动浏览多个 HTML 页面
Scroll through multiple HTML pages with javascript
我有以下 HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Dashboard Example</title>
<style type="text/css">
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
iframe { border: none; }
</style>
<script type="text/javascript">
var Dash = {
nextIndex: 0,
dashboards: [
{url: "C:'CarPositionBrisbane.HTML", time: 5},
{url: "C:'CarPositionCaboolture.HTML", time: 5},
{url: "C:'CarPositionLogan.HTML", time: 5},
{url: "C:'CarPositionWarwick.HTML", time: 5},
{url: "C:'CarPositionHobart.HTML", time: 5},
{url: "C:'CarPositionToowoomba.HTML", time: 5},
{url: "C:'CarPositionIpswich.HTML", time: 5},
{url: "C:'CarPositionYeppoon.HTML", time: 5},
],
display: function()
{
var dashboard = Dash.dashboards[Dash.nextIndex];
frames["displayArea"].location.href = dashboard.url;
Dash.nextIndex = (Dash.nextIndex + 1) % Dash.dashboards.length;
setTimeout(Dash.display, dashboard.time * 1000);
}
};
window.onload = Dash.display;
</script>
</head>
<body>
<iframe name="displayArea" width="100%" height="100%"></iframe>
</body>
</html>
它在谷歌浏览器中完美运行,但我需要让它在IE8中工作,因为它需要在XP机器上运行。
当我在IE中运行以下代码时,我只会得到一个空白屏幕。
有什么建议吗??
仪表板
列表中有一个尾随逗号。所有IE版本都非常严格地解析JavaScript,并且不允许在列表和对象中使用尾随逗号。
检查JavaScript源代码的一个非常有效的方法是使用JSHint,它报告这种错误。
您需要修复代码的以下部分:
// quoting of the "'" in the URLs fixed.
dashboards: [
{url: "C:''CarPositionBrisbane.HTML", time: 5},
{url: "C:''CarPositionCaboolture.HTML", time: 5},
{url: "C:''CarPositionLogan.HTML", time: 5},
{url: "C:''CarPositionWarwick.HTML", time: 5},
{url: "C:''CarPositionHobart.HTML", time: 5},
{url: "C:''CarPositionToowoomba.HTML", time: 5},
{url: "C:''CarPositionIpswich.HTML", time: 5},
{url: "C:''CarPositionYeppoon.HTML", time: 5} // <--- comma removed
],
window.onload 在 IE8 中不起作用:在 IE8 中 window.onload 不起作用
我建议您使用 jQuery 或任何其他处理此类浏览器差异的 JavaScript 库。使用jQuery,它就像编写一样简单。
$(function() {
// insert code here that should be run when the document is ready.
});
相关文章:
- 使用javascript将动态表从一个html页面打印到另一个html页
- 在chrome.tabs.onCreated之后加载HTML页面
- 如何在vs2002中调试html页面
- 使用angular重定向到html页面
- Html页面上的多个Base64图像和平滑加载
- 无法将数据从firebase获取到我的html页面
- 如何在chrome扩展中重定向到html页面
- 如何将值传递到上一个html页面
- AngularJS-需要在index.html页面中访问来自服务的数据
- 如何使用Node/Express显示有关特定错误的自定义html页面
- 如何在 html 页面中调用 jquery
- 加载存储在IndexedDB中的HTML页面
- 同一HTML页面中的两个不同版本的JQuery
- HTML页面如何提取通过表单传递的参数
- 在HTML页面上将URL解析为可读的json格式
- 使用jQuery插入HTML页面的第一个项目缺少结束标记
- 在HTML页面上显示node.js服务器中的数据
- 加载页面时更改html页面的位置
- Ajax调用返回当前html页面,而不是请求的文件
- css是从远程node.js添加的,但不适用于html页面