希望有人能够帮忙。我无法在Firefox中使用下面的代码打开没有地址栏的新窗口。但IE可以正常工作。
window.open('/pageaddress.html', 'winname',
directories=0,titlebar=0,toolbar=0,location=0,status=0,
menubar=0,scrollbars=no,resizable=no,
width=400,height=350);
我需要为所有浏览器进行设置
希望有人能够帮忙。我无法在Firefox中使用下面的代码打开没有地址栏的新窗口。但IE可以正常工作。
window.open('/pageaddress.html', 'winname',
directories=0,titlebar=0,toolbar=0,location=0,status=0,
menubar=0,scrollbars=no,resizable=no,
width=400,height=350);
我需要为所有浏览器进行设置
Firefox 3.0及更高版本默认禁用了location
的设置,resizable
和status
也被默认禁用。您可以在地址栏中键入“about:config”并按“dom”进行过滤,以验证此信息。相关条目包括:
您可以在Mozilla开发者网站上获取更多信息。但基本上这意味着您将无法实现所需功能。
您可能想要做的一件事(虽然这不能解决您的问题),是在窗口特性参数周围加上引号,如下所示:
window.open('/pageaddress.html','winname','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');
我同意在现代浏览器中无法隐藏地址栏,但我们可以隐藏地址栏中的URL(例如显示URL about:blank
)。以下是我的解决方案:
var iframe = '<html><head><style>body, html {width: 100%; height: 100%; margin: 0; padding: 0}</style></head><body><iframe src="https://www.w3schools.com" style="height:calc(100% - 4px);width:calc(100% - 4px)"></iframe></body></html>';
var win = window.open("","","width=600,height=480,toolbar=no,menubar=no,resizable=yes");
win.document.write(iframe);
查看mozilla window.open 文档。 窗口特性(如“directory=...,...,height=350”)等参数应为字符串:
window.open('/pageaddress.html','winname',"directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,width=400,height=350");
在您的浏览器上尝试一下是否可行。请注意,一些功能可能会被用户偏好设置覆盖,例如"位置"(请参阅文档)。
windowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes"
或 windowFeatures = "menubar=no,location=no,resizable=no,scrollbars=no,status=no"
没有任何区别,即结果完全相同。 - Apostolos解决方案 - 打开一个模态弹出窗口并嵌入外部网址作为iframe。
在 Internet Explorer 中,如果新的 URL 与当前 URL 属于同一个域名,那么窗口将会在没有地址栏的情况下打开。否则,它会导致地址栏出现。一种解决方法是先打开同一域名下的页面,然后再从该页面重定向。
检查一下,如果它能正常工作,那对我来说就很好了。
var windowObjectReference;
var strWindowFeatures = "menubar=no,location=no,resizable=no,scrollbars=no,status=yes,width=400,height=350";
function openRequestedPopup() {
windowObjectReference = window.open("http://www.flyingedge.in/", "CNN_WindowName", strWindowFeatures);
}
openRequestedPopup();