【发布时间】:2014-05-15 19:47:34
【问题描述】:
我有一堆网页,其中我有一个相同的结构:
<html>
<head>
<script src="sorttable.js"></script>
<noscript>
<meta http-equiv="refresh" content="60">
</noscript>
<script type="text/javascript">
<!--
var sURL = unescape(window.location.pathname);
function doLoad()
{
setTimeout( "parent.frames['header_frame'].document.submitform.submit()", 60*1000 );
}
function refresh()
{
window.location.href = sURL;
}
//-->
</script>
<script type="text/javascript">
<!--
function refresh()
{
window.location.replace( sURL );
}
//-->
</script>
<script type="text/javascript">
<!--
function refresh()
{
window.location.reload( true );
}
//-->
</script>
</head>
<body>
.
.
.
<script type="text/javascript">
window.onload = function() { sorttable.innerSortFunction.apply(document.getElementById("OpenFace-2"), []); doLoad(); }
</script>
</body>
</html>
这在每个页面都可以完美运行,除了一个页面,当 onload 函数运行时,它找不到可排序的代码(从顶部的 sorttable.js 加载)。所有这些页面都是同一个应用程序的一部分,并且都与 js 文件位于同一个目录中。在加载该页面之前,我在 apache 日志或 js 控制台中没有收到任何错误,当我得到:
sorttable.innerSortFunction is undefined
我看不出是什么让这一页与众不同。谁能看到这里出了什么问题,或者给我一些关于如何进一步调试的指示?
我粘贴的代码来自它不起作用的页面的源代码,但它与它起作用的页面相同。
【问题讨论】:
-
不要在字符串中使用
setTimeout或setInterval,因为它就像邪恶的eval!改用函数:setTimeout(parent.frames['header_frame'].document.submitform.submit, 60e3) -
@Luxelin - 是的,这就是我们正在使用的排序表
-
所有页面都在同一个路径中吗?控制台浏览器中有任何消息吗?如果此页面在其他路径,则需要将
-
@Oriol - 但这不是问题 - doLoad() 函数有效 - 抛出错误的是 window.onload()。但为了确保我做出了您建议的更改 - 它并没有解决我的问题,并且导致我的页面不断刷新,而不是每分钟刷新一次。
标签: javascript html sorttable.js