【发布时间】:2013-08-23 11:06:26
【问题描述】:
我正在使用 Smarty 模板系统。它的功能之一是可以输出为每个页面生成调试信息的脚本。在这里你可以看到一个生成代码的例子:
<script type="text/javascript">
//<![CDATA[
setTimeout(function() { //Attempt to fix the issue with timeout
var _smarty_console = window.open("about:blank","md5hash","width=680,height=600,resizable,scrollbars=yes");
console.log(_smarty_console); //Trying to log it
if(_smarty_console!=null) {
_smarty_console.document.write("<!DOCTY... lots of HTML ...<\/html>\n");
_smarty_console.document.close();
}
}, 5000);
//]]>
</script>
问题是,window.open 函数总是返回 null。我试图用setTimeout 推迟它,但没有任何改变。当我复制代码并在 Firebug 控制台中运行它时,它可以正常工作。页面上没有其他脚本。该页面使用严格的 XHTML。脚本就在</body>之前。
【问题讨论】:
-
这可能是一个愚蠢的问题,但你真的能看到弹出窗口吗?如果不能,请关闭浏览器中的弹出窗口拦截器...