javascript 在弹出窗口中禁用浏览器的位置栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3581926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 01:36:47  来源:igfitidea点击:

Disable Location Bar of Browsers in Pop-up Windows

javascripthtml

提问by Narazana

I have the following HTML with Javascript:

我有以下带有 Javascript 的 HTML:

<A HREF="javascript:void(0)"onclick="window.open('http://www.msn.com/','New Windows','height=380, width=300,location=no')">Hide Address Bar</a>

It's working fine with IE but not FireFox 3 and later.

它适用于 IE,但不适用于 FireFox 3 及更高版本。

I want to disable the "Location" bar when pop-up windows shows up.

我想在弹出窗口出现时禁用“位置”栏。

回答by Kranu

The problem is not an error in your syntax. The problem is security concerns. If people could hide the address bar, people would be able to recreate login pages such as Paypal and people would be tricked into logging into them and giving a malicious hacker their password.

问题不是语法错误。问题是安全问题。如果人们可以隐藏地址栏,人们将能够重新创建诸如 Paypal 之类的登录页面,并且人们将被诱骗登录这些页面并向恶意黑客提供密码。

As a result, most of the latest browsers disable hiding the location bar, although in some browsers, setting location=no will disable the address bar from being modified.

因此,大多数最新的浏览器都禁止隐藏地址栏,尽管在某些浏览器中,设置 location=no 将禁止修改地址栏。

回答by Quentin

Modern browsers do not allow you to hide the address bar (as an anti-phishing measure). There should be no way around this.

现代浏览器不允许您隐藏地址栏(作为一种反网络钓鱼措施)。应该没有办法解决这个问题。