javascript 在 html 文件中禁用浏览器中的地址栏和后退按钮

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

Disable address bar and back button in browser in html file

javascriptjqueryhtml

提问by Hassan Sardar

How can I disable address bar and back button in browser in html file?

如何在 html 文件中禁用浏览器中的地址栏和后退按钮?

Something Like this :

像这样的东西:

Here is the demo :http://jsfiddle.net/n5pKP/5/

这是演示:http: //jsfiddle.net/n5pKP/5/

JS:

JS:

$('.popup').click(function () {
    var curr_browser = navigator.appName;
    if (curr_browser == "Microsoft Internet Explorer") {
        window.opener = self;
    }
    window.open('http://www.google.com/', 'null', 'width=900,height=750,toolbar=no,scrollbars=no,location=no,resizable =no');
    window.moveTo(0, 0);
    window.resizeTo(screen.width, screen.height - 100);
});

HTML:

HTML:

<a target="_parent" href="javascript:void(0);" class="popup">Open new window</a> 

Right now its opening on click. I want to open it directly as popup. Like I double click on test.html , its should appear my html data and disabled address bar and with no back button.

现在它的开放点击。我想直接作为弹出窗口打开它。就像我双击 test.html 一样,它应该显示我的 html 数据和禁用的地址栏,并且没有后退按钮。

How it can be done?

怎么做?

回答by Rathod Paresh

You may try like this

你可以试试这样

<input id="Button1" type="button" value="button" onclick="window.open('WebForm1.aspx','PoP_Up','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=1024,height=768');" />

This is supported in top browser

这在顶级浏览器中受支持

回答by ambrosechua

The JavaScript API exists, just that due to security issues, browser vendors disabled the hiding of the address bar.

JavaScript API 存在,只是由于安全问题,浏览器供应商禁用了地址栏的隐藏。

Hiding the address bar of a browser

隐藏浏览器地址栏

Instead, you could make a modal within the browser window. Twitter Bootstrap or something like this: http://sandbox.scriptiny.com/tinybox2/

相反,您可以在浏览器窗口中创建一个模态。Twitter Bootstrap 或类似的东西:http: //sandbox.scriptiny.com/tinybox2/