在 Firefox 和 IE 中打开没有地址栏的新弹出窗口
-
04-10-2019 - |
题
希望有人可以帮忙。只是无法在没有地址栏的 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
默认情况下也被禁用。您可以通过在地址栏中键入``大约:config''并通过“ dom”过滤来验证此问题。感兴趣的项目是:
- dom.disable_window_open_feature.location
- dom.disable_window_open_feature.sizable
- dom.disable_window_open_feature.status
您可以在 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');
其他提示
检查 window.open 上的 mozilla 文档。窗口功能(“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");
尝试一下在您的浏览器中是否有效。请注意,某些功能可能会被用户首选项覆盖,例如“位置”(请参阅文档)。
解决方法 - 打开模态弹出窗口,并将外部URL嵌入为iframe。
我知道这是一个非常古老的问题,是的,我同意我们不能在现代浏览器中隐藏地址栏,但是我们可以在地址栏中隐藏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></html></body>';
var win = window.open("","","width=600,height=480,toolbar=no,menubar=no,resizable=yes");
win.document.write(iframe);
在Internet Explorer中,如果新URL来自与当前URL相同的域,则该窗口将在没有地址栏的情况下打开。否则,它将导致地址栏出现。一个解决方法是从同一域打开页面,然后从该页面重定向。
检查一下是否有效,对我有效
<script>
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);
}
</script>
不隶属于 StackOverflow