66

希望有人可以提供帮助。只是无法在没有地址栏的情况下在 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);

我需要为所有浏览器制作

4

6 回答 6

87

Firefox 3.0 及更高版本默认禁用设置locationresizable并且status默认情况下也被禁用。您可以通过在地址栏中键入“about:config”并按“dom”过滤来验证这一点。感兴趣的项目是:

  • dom.disable_window_open_feature.location
  • dom.disable_window_open_feature.resizable
  • 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');
于 2010-05-26T01:58:10.643 回答
18

我知道这是一个非常古老的问题,是的,我同意我们不能在现代浏览器中隐藏地址栏,但我们可以在地址栏中隐藏 url(例如 show 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);
于 2019-01-05T12:25:46.740 回答
17

检查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");

试试这是否适用于您的浏览器。请注意,某些功能可能会被用户首选项覆盖,例如“位置”(参见 doc.)

于 2010-05-26T01:57:46.027 回答
12

解决方法 - 打开模式弹出窗口并将外部 URL 嵌入为 iframe。

于 2014-06-12T15:40:09.723 回答
3

在 Internet Explorer 中,如果新 url 与当前 url 来自同一个域,则窗口将打开而没有地址栏。否则会导致出现地址栏。一种解决方法是从同一域打开一个页面,然后从该页面重定向。

于 2014-07-27T16:57:07.070 回答
0

检查它是否有效,对我来说效果很好

<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>
于 2013-06-24T13:23:48.670 回答