简体   繁体   English

带window.open的垂直滚动条

[英]Vertical scrollbars with window.open

I am opening a popop windows with window.open. 我正在用window.open打开一个popop窗口。 I want the scrollbars to show up if needed. 如果需要,我希望滚动条显示出来。 However in safari, the scrollbars are not showing up unless I set, scrollbars=1, 但是在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. “如果需要,只显示水平滚动条”到popop窗口。

(Possibly via some combinations of options to window.open, and overflow, css property.) (可能通过window.open和overflow,css属性的一些选项组合。)

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. 但水平滚动条不应显示。

经过大量搜索后我发现这个很合适

window.open("http://www.classi5.blogspot.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM