如何使用 JavaScript 隐藏浏览器地址栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3827962/
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 02:23:52  来源:igfitidea点击:

How to hide the browser address bar with JavaScript

javascriptbrowser

提问by Asad

Is it possible to hide the user's address bar in the browser? If so, how would I go about it?

是否可以在浏览器中隐藏用户的地址栏?如果是这样,我将如何处理?

回答by Matthew Manela

I don't think you can hide the address bar on a user's current window but you can create a pop up that has the address bar hidden:

我认为您不能隐藏用户当前窗口上的地址栏,但您可以创建一个隐藏地址栏的弹出窗口:

var popup = window.open("http://someurl", "myPopup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=120,height=120')

回答by vol7ron

You can create a modelesswindow (IE), but you cannot hiHyman the browser's current page.

您可以创建无模式窗口 (IE),但无法劫持浏览器的当前页面。

FF does not support this as it took them 3 years to implement the showModalDiaglog, which was more secure than IE's implementation.

FF 不支持这一点,因为他们花了 3 年时间才实现了比 IE 的实现更安全的 showModalDiaglog。

Your option is to:

您的选择是:

  • Open a new window, hiding the address bar, but it would still be available
  • Create an absolutely positioned element w/in the current page that contains an iframe
  • Create your own browser and add that feature
  • 打开一个新窗口,隐藏地址栏,但它仍然可用
  • 在包含 iframe 的当前页面中创建一个绝对定位的元素
  • 创建您自己的浏览器并添加该功能

回答by Juan Mendes

Can't do it reliably and it's not a good idea, even for popups, I think currently, IE is the only one that will hide it. Otherwise the user doesn't know where the popup is from. Think about the facebook login popup. How am I supposed to be confident that I'm not entering my password into a malicious website?

不能可靠地做到这一点,这不是一个好主意,即使对于弹出窗口,我认为目前,IE 是唯一会隐藏它的人。否则用户不知道弹出窗口来自哪里。想想 facebook 登录弹出窗口。我应该如何确信我没有将密码输入恶意网站?