Javascript 如何使用javascript window.open隐藏地址栏?

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

How to hide address bar using javascript window.open?

javascriptcross-browseraddress-bar

提问by VolleyBall Player

I want to disable the address bar using javascript window.open. Also the script should work in IE, Safari and chrome. Any suggestions.

我想使用 javascript 禁用地址栏window.open。此外,该脚本应该适用于 IE、Safari 和 chrome。有什么建议。

采纳答案by Paragon

(untested)

(未经测试)

function openWindow(){
var browser=navigator.appName;
if (browser==”Microsoft Internet Explorer”)
{
window.opener=self;

}
window.open(‘filename.htm','null','width=900,height=750,
toolbar=no,scrollbars=no,location=no,resizable =yes');
window.moveTo(0,0);
window.resizeTo(screen.width,screen.height-100);
self.close();
}

Got this from http://saher42.wordpress.com/2006/08/10/hiding-the-address-bar-on-pageload-using-javascript/.

http://saher42.wordpress.com/2006/08/10/hiding-the-address-bar-on-pageload-using-javascript/得到这个。

回答by daniellmb

locationis the window feature you want to set to noor 0to hide the address bar.

location是您要设置no0隐藏地址栏的窗口功能。

Opinionated Advice: You can't rely on popups showing because most people have popup blockers installed to curb abuse, so if you can get away with it, don't use a pop up at all! Use something like the jQuery UI Dialogplugin.

意见建议:您不能依赖弹出窗口的显示,因为大多数人都安装了弹出窗口阻止程序来遏制滥用行为,所以如果您能侥幸成功,根本不要使用弹出窗口!使用类似jQuery UI Dialog插件的东西。

Example:

例子:

window.open("http://www.mydomain.com/mypage.htm", "mywindow", "location=0,menubar=0,status=0,scrollbars=0,width=100,height=100");

window.open(" http://www.mydomain.com/mypage.htm", "mywindow", " location=0,menubar=0,status=0,scrollbars=0,width=100,height=100") ;

Format

格式

window.open( [Url] [, Name] [, Features] [, History] )

window.open( [Url] [, Name] [, Features] [, History] ​​)

Window features you can control

您可以控制的窗口功能

  • statusThe status bar at the bottom of the window.
  • toolbarThe standard browser toolbar, with buttons such as Back and Forward.
  • locationThe Location entry field where you enter the URL.
  • menubarThe menu bar of the window
  • resizableAllow/Disallow the user to resize the window.
  • scrollbarsEnable the scrollbars if the document is bigger than the window
  • heightSpecifies the height of the window in pixels. (example: height='350′)
  • widthSpecifies the width of the window in pixels.
  • status窗口底部的状态栏。
  • 工具栏标准浏览器工具栏,带有后退和前进等按钮。
  • 位置您在其中输入 URL 的位置输入字段。
  • menubar窗口的菜单栏
  • resizable允许/禁止用户调整窗口大小。
  • scrollbars如果文档大于窗口,则启用滚动条
  • height以像素为单位指定窗口的高度。(例如:高度='350')
  • width以像素为单位指定窗口的宽度。

回答by Bene Laci

Also you have to enable window.opento hide the address bar in Firefox, which is disabled by default. Go to about:config, search for disable_window_open, so you can see all window.openfeature disabling options, including dom.disable_window_open_feature.location, which is responsible for the address bar not hiding. Set it to false.

您还必须启用window.open以隐藏 Firefox 中的地址栏,默认情况下该地址栏是禁用的。转到about:config,搜索disable_window_open,这样您就可以看到所有window.open功能禁用选项,包括dom.disable_window_open_feature.location,它负责不隐藏地址栏。将其设置为false

回答by williams

Type in the address bar of Firefox like this about:config,

像这样在 Firefox 的地址栏中输入 about:config,

search for disable_window_open, so you can see all window.open feature

搜索 disable_window_open,以便您可以看到所有 window.open 功能