windows 打开没有菜单栏的浏览器窗口(JavaScript?)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2081456/
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
Open browser windows without menu bars (JavaScript?)
提问by caw
The users in my community want the chat to be opened in a small window without all the control bars.
我社区中的用户希望在没有所有控制栏的小窗口中打开聊天。
So I think a popup window without scroll bars, location bar, status bar and so on would be the best solution. Right?
所以我认为没有滚动条、位置栏、状态栏等的弹出窗口将是最好的解决方案。对?
What is the best way to have such a popup window? JavaScript? Can I do it like this?
有这样一个弹出窗口的最佳方法是什么?JavaScript?我可以这样做吗?
BETWEEN AND
之间
<script type="text/javascript">
<!--
var win = NULL;
onerror = stopError;
function stopError(){
return true;
}
function openChat(){
settings = "width=640, height=480, top=20, left=20, scrollbars=no, location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=no, dependent=no";
win = window.open('http://www.example.org/chat.html', 'Chat', settings);
win.focus();
}
// -->
</script>
BETWEEN AND
之间
<a href="#" onclick="openChat(); return false">Open chat</a>
ON CHAT.HTML
在聊天.HTML
<form><input type="submit" value="Close chat" onClick="window.close()"></form>
回答by Miguel Ventura
If you want the new window not to have the menu bars and toolbars, the only way to do it is through JavaScript as with the example you provided yourself. However keep in mind that most browsers, nowadays, ignore what you set for the status bar (always show it) and may be configured to also always show the remaining toolbars. If a browser is configured in such a way there's no escaping it, although the default should be that you'll only get the status bar and perhaps the address bar.
如果您希望新窗口没有菜单栏和工具栏,唯一的方法是通过 JavaScript,就像您自己提供的示例一样。但是请记住,现在大多数浏览器会忽略您为状态栏设置的内容(始终显示它),并且可能被配置为始终显示剩余的工具栏。如果浏览器以这种方式配置,则无法对其进行转义,尽管默认设置应该是您只会获得状态栏和地址栏。
回答by Crozin
Your solution is good, but there are alternatives. You can create the window by your own, as some kind of layer. Then you need to implement lots of things but it gives you full control over window Look And Feel. Of course you can always use some scripts like jQuery UI Dialog.
您的解决方案很好,但还有其他选择。您可以自己创建窗口,作为某种层。然后你需要实现很多东西,但它可以让你完全控制 window Look And Feel。当然,您始终可以使用一些脚本,例如jQuery UI Dialog。