Vertical scrollbars with window.open

49,633

Solution 1

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.

Solution 2

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" 
Share:
49,633

Related videos on Youtube

agiliq
Author by

agiliq

We are agiliq. We build amazing web apps. @agiliqdotcomgooglefacebooklinkedin

Updated on July 09, 2022

Comments

  • agiliq
    agiliq almost 2 years

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

    • David Kolar
      David Kolar almost 14 years
      scrollbars=1 is exactly what you need (though you've mistyped it in your question). Perhaps there is something in the popup page that is wider than you think.
  • JoeBrockhaus
    JoeBrockhaus about 10 years
    scrollbars will not be present by default with window.open() so you have to add the option to show them if you want them
  • Jahid
    Jahid about 8 years
    What's the status=1 for?

Related