【问题标题】:Javascript window.open() toolbar=no not functioningJavascript window.open() 工具栏=没有不起作用
【发布时间】:2020-01-07 12:03:30
【问题描述】:

我正在尝试用最少的附加功能(工具栏、菜单栏、地址栏等)在 Firefox 中打开一个 html 文件。只是网页的html内容,没有别的。我希望能够从终端在 linux 中执行此操作。我还必须以这样一种方式做到这一点,即它可以在运行相同版本的 Firefox 的多台 linux 机器上工作。因此,这消除了使用配置文件的任何可能性。我希望 Firefox 有一个简单的参数可以让我关闭这些设置。我不相信有。

我发现的唯一可能性是通过 javascript 的 window.open。似乎 window.open 的参数规范甚至在 firefox 1.5.0.9 中也不起作用。我读到其中一些已在 firefox 3.0+ 中删除,但没有发现任何关于我正在使用的版本 1.5.0.9 的信息。

这是我用来使用 windows.open 打开我的 .html 文件的内容...

test.html:

    <html>
    <body>
    <script>
    window.open('./rel_notes.html','_self','toolbar=no,menubar=no')
    </script>
    </body>
    </html>

然后从终端运行“firefox test.html”。

当我这样做时,工具栏和菜单栏仍然出现。我究竟做错了什么?有没有更简单的方法来做到这一点?

【问题讨论】:

标签: javascript html linux firefox window.open


【解决方案1】:

如果您的浏览器设置允许没有来自 X 源(我猜是本地主机?)通知的弹出窗口,那么以下可能会起作用:


window.open('./rel_notes.html',null,'menubar=no,toolbar=no');
window.open('','_self',''); //this is needed to prevent IE from asking about closing the window.
setTimeout('self.close();',500);

【讨论】:

  • 不要将字符串传递给setTimeout
  • @SLaks 没错,如果你是“eval is evil”的追随者。不过,这并不是问题的重点。
【解决方案2】:

取自 bungdito 给我的链接中的一个链接:

    After a window is opened, JavaScript can't be used to change the features. 

因此,通过打开 test.html,然后在 _self 上使用 window.open,我正在尝试使用 javascript 将功能调整为已打开的窗口。

来源:https://developer.mozilla.org/en-US/docs/DOM/window.open

【讨论】:

    猜你喜欢
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 2014-12-25
    • 1970-01-01
    • 2015-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多