Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do window.open with no scrollbars in Google Chrome

The following code opens the new window without scrollbars in Firefox, IE and Opera.

    var options = {
        height: 300, // sets the height in pixels of the window.
        width: 300, // sets the width in pixels of the window.
        toolbar: 0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
        scrollbars: 0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
        status: 0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
        resizable: 1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
        left: 0, // left position when the window appears.
        top: 0, // top position when the window appears.
        center: 0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
        createnew: 0, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
        location: 0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
        menubar: 0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
    };

    var parameters = "location=" + options.location +
                     ",menubar=" + options.menubar +
                     ",height=" + options.height +
                     ",width=" + options.width +
                     ",toolbar=" + options.toolbar +
                     ",scrollbars=" + options.scrollbars +
                     ",status=" + options.status +
                     ",resizable=" + options.resizable +
                     ",left=" + options.left +
                     ",screenX=" + options.left +
                     ",top=" + options.top +
                     ",screenY=" + options.top;

    // target url
    var target = 'some url'  

    popup = window.open(target, 'popup', parameters);

In Google Chrome the new window still has the scrollbars. Any ideas to make it work?

like image 808
Pawel Furmaniak Avatar asked Jan 03 '10 13:01

Pawel Furmaniak


People also ask

How do I disable scrollbar in chrome?

2. Type "Remove Scrollbars" (without quotes) in the search box and press "Enter." Click the "Remove Scrollbars" option located on top of the search results.

How do you scroll down if there is no scroll bar?

Go to Settings / Ease of Access / Display and turn off Automatically hide scroll bars in Windows.

How do I get rid of the scroll bar in Windows?

Go to Ease of Access > Display. Find the "Automatically hide scroll bars in Windows" preference and set it to off.


2 Answers

This style should do the trick, add it to the opened window document:


body{ overflow-x:hidden;overflow-y:hidden; }
like image 198
DoctorLouie Avatar answered Sep 17 '22 04:09

DoctorLouie


You shouldn't remove scrollbars. If I have my font setting insanely large and didn't know of other ways to scroll other than scrollbars, I won't be able to actually view the content of the popup. Same goes for overflow: hidden. Just don't do it, as there is no way to make sure the content of the page will fit in an exact size. Scrollbars don't appear by default if the page isn't overflowing, so your problem is most likely that your popup is too small for the page you're loading in it. Also, most people hate popups, so you may want to try a less-intrusive approach, such as small yet exuberantly colored box to grab the user's attention.

like image 41
Eli Grey Avatar answered Sep 18 '22 04:09

Eli Grey