Javascript 带有 window.open 的垂直滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2957325/
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
Vertical scrollbars with window.open
提问by agiliq
I am opening a popop windows with window.open. I want the scrollbars to show up if needed. However in safari, the scrollbars are not showing up unless I set, scrollbars=1,
我正在用 window.open 打开一个弹出窗口。如果需要,我希望滚动条显示出来。但是在 safari 中,除非我设置,scrollbars=1,否则滚动条不会显示,
However that makes even horizontal scrollbars show up. Is there a way to specify,
然而,这甚至会显示水平滚动条。有没有办法指定,
"Show only horizontal scrollbars, if needed" to popop window.
“如果需要,只显示水平滚动条”到弹出窗口。
(Possibly via some combinations of options to window.open, and overflow, css property.)
(可能通过 window.open 和 overflow、css 属性的一些选项组合。)
回答by Tauren
I've been messing with this a little and I settled on this solution until I find a better one:
我一直在搞这个,我决定使用这个解决方案,直到找到更好的解决方案:
window.open('http://yoursite.com','mypopup',
'status=1,width=500,height=500,scrollbars=1');
Then in the CSS of yoursite.com, put this:
然后在 yoursite.com 的 CSS 中,输入:
html {
overflow-x: hidden;
overflow-y: auto;
}
In some browsers, a vertical scrollbar may show even if the content fits in the window. But the horizontal scroll bar should not show.
在某些浏览器中,即使内容适合窗口,也可能会显示垂直滚动条。但是水平滚动条不应该显示。
回答by BLOGBIR
After searching a lot I found this suitable
经过大量搜索,我发现这个合适
window.open("http://www.classi5.blogspot.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"

