javascript 隐藏浏览器的地址栏(弹出)

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

Hiding the address bar of a browser (popup)

javascript

提问by Surendra Jnawali

I have to hide the address bar of a browser. I am using this code:

我必须隐藏浏览器的地址栏。我正在使用此代码:

var winFeature =
        'location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes';
window.open('Result.html','null',winFeature);  

In many solutions, just the location=noattribute can hide the address bar (in both IE & Chrome). However, this didn't work for me (even in IE & Chrome).

在许多解决方案中,仅location=no属性就可以隐藏地址栏(在 IE 和 Chrome 中)。但是,这对我不起作用(即使在 IE 和 Chrome 中)。

Finally, I found a MSDN articlethat describes how location=nosimply hides the back/forward/stop navigation buttons, and makes the address bar read-only.

最后,我找到了一篇 MSDN 文章,描述了如何location=no简单地隐藏后退/前进/停止导航按钮,并使地址栏只读

Is there any solution to hide the entire address bar by ignoring above MSDN article?I am testing in IE and Google Chrome.

有没有办法通过忽略上面的 MSDN 文章来隐藏整个地址栏?我正在 IE 和 Google Chrome 中进行测试。

回答by Quentin

What is the truth?

真相是什么?

Microsoft's documentation describing the behaviour of their browser is correct.

Microsoft 描述其浏览器行为的文档是正确的。

Is there any solution to hide the addressbar?

有没有办法隐藏地址栏?

No. If you could hide it, then you could use HTML/CSS to make something that looked like a common address bar. You could then put a different address in it. You could then trick people into thinking they were on a different site and entering their password for it.

不。如果你可以隐藏它,那么你可以使用 HTML/CSS 来制作看起来像一个普通地址栏的东西。然后,您可以在其中输入不同的地址。然后,您可以诱使人们认为他们在不同的站点上并为其输入密码。

It is impossible to conceal the user's location from them because it is essential for security that they know what their location is.

向他们隐藏用户的位置是不可能的,因为他们知道他们的位置对安全来说是必不可少的。

回答by Pekka

This is no longer possible in modern browsers due to security restrictions.

由于安全限制,这在现代浏览器中不再可能。

Official(-ish) Sources:

官方(-ish)来源:

  • Firefox

    In Firefox 3, dom.disable_window_open_feature.location now defaults to true, forcing the presence of the Location Bar much like in IE7. See bug 337344 for more information.

  • Internet Explorer 7 and later

    In Internet Explorer 6, location specifies whether to display the Address Bar.

    (Implying the behaviour ends with IE6)

  • Chrome/Chromium

    Those toolbar hiding parameters are ignored in Chrome. You will also notice that modern browsers are moving towards not hiding it as security / anti phishing measures. Also see https://bugzilla.mozilla.org/show_bug.cgi?id=337344

  • 火狐

    在 Firefox 3 中,dom.disable_window_open_feature.location 现在默认为 true,强制显示位置栏,就像在 IE7 中一样。有关更多信息,请参阅错误 337344。

  • Internet Explorer 7 及更高版本

    在 Internet Explorer 6 中,location 指定是否显示地址栏。

    (暗示行为以 IE6 结束)

  • 铬/铬

    Chrome 中会忽略这些工具栏隐藏参数。您还会注意到,现代浏览器正朝着不将其隐藏作为安全/反网络钓鱼措施的方向发展。另见https://bugzilla.mozilla.org/show_bug.cgi?id=337344

回答by GTRONICK

Looking for the same, the only thing I'm able to do is

寻找相同的,我唯一能做的就是

Launch Google Chromein app mode

在应用模式下启动谷歌浏览器

Chrome.exe --app="<address>"

From the run prompt. Example:

从运行提示。例子:

Chrome.exe --app="http://www.google.com"

Hide the address bar in Mozilla Firefox

Mozilla Firefox 中隐藏地址栏

Type about:configin the address bar, the search for:

输入about:config在地址栏,搜索:

dom.disable_window_open_feature.location

And set it to false

并将其设置为 false

So, when you open a popup window, it will launch with the address bar hidden. For example:

因此,当您打开一个弹出窗口时,它将在隐藏地址栏的情况下启动。例如:

window.open("http://www.google.com",'','postwindow');

Firefox without location bar

没有位置栏的 Firefox

Chrome in app mode

应用模式下的 Chrome

Now, I'm looking to do something similar with Microsoft Edge, I have not found anything yet for this browser.

现在,我希望用 Microsoft Edge 做一些类似的事情,但我还没有为这个浏览器找到任何东西。

回答by yunzen

It's different in every browser.

每个浏览器都不一样。

Some years ago, what you tried, was right. But nowadays it is regarded as a security risk by browser vendors that one cannot see the browsers address bar (for phishing reasons) and so they (or most of them) made the decision to always show the browser address bar. Which is good in my eyes.

几年前,您尝试的方法是正确的。但如今浏览器供应商将无法看到浏览器地址栏(出于网络钓鱼的原因)视为一种安全风险,因此他们(或大多数)决定始终显示浏览器地址栏。这在我看来很好。

回答by Joseph

There is no definite way to do that. JS may have the API, but the browser vendor may choose not to implement it or implement it in another way.

没有明确的方法可以做到这一点。JS 可能有 API,但浏览器供应商可能会选择不实现它或以其他方式实现它。

Also, as far as I remember, Opera even provides the user preferences to prevent JS from making such changes, like have the window move, change status bar content, and stuff like that.

此外,据我所知,Opera 甚至提供了用户首选项来防止 JS 进行此类更改,例如移动窗口、更改状态栏内容等等。

回答by Joseph

Its not possible to hide address bar of browser.

无法隐藏浏览器的地址栏。

回答by T04435

You might no be able to HIDE it, but if you are looking for the extra space, what I did and seems to work is a very simple thing, the address barhas 60px height, so this is my solution.

你可能无法隐藏它,但如果你正在寻找额外的空间,我所做的并且似乎工作是一件非常简单的事情,地址栏有 60px 高度,所以这是我的解决方案。

@media only screen and (max-width: 1024px){ // only from ipads down
  body{
    padding-bottom: 60px; // push your whole site same height upwards. ;)
  }
}

回答by brvnbld

You could make the webpage scroll down to a position where you can't see the address bar, and if the user scrolls, the page should return to your set position. In that way, Mobile browsers when scrolled down , will try to guve you full-screen experience. So it will hide the address bar. I don't know the code, someone else might put up the code.

你可以让网页向下滚动到你看不到地址栏的位置,如果用户滚动,页面应该回到你设置的位置。这样,当向下滚动时,移动浏览器会尝试为您提供全屏体验。所以它会隐藏地址栏。我不知道代码,其他人可能会贴出代码。

回答by Cyberlex

you can do it with visual Basic, put a Webbrowser control on the form, load an html that opens a popup with Location=noand it will open a new browser without address bar. Probably not what you are looking for but just thought throw it in :)

你可以用visual Basic来做,在窗体上放一个Webbrowser控件,加载一个打开弹出窗口的html,Location=no它会打开一个没有地址栏的新浏览器。可能不是你要找的东西,只是想把它扔进去:)

回答by krmarshall87

This is how I do it for popups, though it is only working with IE11, not Chrome- haven't tested in Firefox.

这就是我对弹出窗口的处理方式,尽管它仅适用于 IE11,而不适用于 Chrome-尚未在 Firefox 中进行测试。

window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');