Javascript 如何在 Chrome 中禁用弹出窗口的位置栏和滚动条?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6748246/
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
How to disable location bar and scroll bars of pop window in Chrome?
提问by umar
For the following code width and height are working in Chrome but location and scrollbar are not working. Please guide.
对于以下代码,宽度和高度在 Chrome 中有效,但位置和滚动条无效。请指导。
<script language="JavaScript">
function newwindow() {
window.open('http://localhost/a.php', 'jav',
'width=300,height=200,resizable=yes,location=no,scrollbars=no');
}
</script>
<a href="javascript:newwindow()">Click Here</a>
回答by James Montagne
Chrome will not allow you to do this for security reasons. Hiding the address bar makes it easier to pretend you're somebank.comwhen really you're somenigerianguy.com.
出于安全原因,Chrome 不允许您这样做。隐藏地址栏可以让你更容易假装你是somebank.com,而实际上你是somebank.com。
As for the scrollbar, you can use css on a.php
to hide the scrollbars by setting overflow: hidden
.
至于滚动条,你可以使用 css ona.php
通过设置来隐藏滚动条overflow: hidden
。
回答by BALKANGraph
To hide the scrollbar: try setting "overflow: hidden;" in the css
隐藏滚动条:尝试设置“溢出:隐藏;” 在css中
You can't open a popup without location bar like in IE, to workaround this you could use an iframe or some third party jQuery plugin
您无法像在 IE 中那样在没有位置栏的情况下打开弹出窗口,要解决此问题,您可以使用 iframe 或某些第三方 jQuery 插件