Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical scrollbars with window.open

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,

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.)

like image 927
agiliq Avatar asked Jun 02 '10 11:06

agiliq


People also ask

What are the two types of scrollbars?

There are two types of scroll bars: vertical and horizontal.

How do I turn on the vertical scroll bar?

Show scroll bars in Word and Excel for WindowsClick File > Options. On the Advanced tab, scroll to the Display section. Select Show horizontal scroll bar and Show vertical scroll bar, and then click OK.

Why do I have two vertical scrollbars?

You're basically getting a double scrollbar because your giving the body min-height of 100vh AND setting an overflow. It appears this was done to keep the menu in the correct position on mobile devices. That fixed things in Chrome, I assume other browsers as well but I didn't do any heavy testing.

How do I scroll vertically?

For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.


1 Answers

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:

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.

like image 179
Tauren Avatar answered Sep 23 '22 00:09

Tauren