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

后端 未结 4 455
予麋鹿
予麋鹿 2020-12-13 16:10

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

    var options = {
        height: 300, // sets the h         


        
4条回答
  •  既然无缘
    2020-12-13 16:44

    Google Chrome goes the extra mile for users by automatically capturing many popups and suppressing them into a notification area in the bottom-right corner of the browser, giving the user the option to manually launch them or not. Additionally Google pushes updates to browsers regularly and if your popup isn't captured by Chrome now it might be in the future.

    Also many tools on systems nowadays prevent or block popups so the odds are against your popup on many levels.

    Recommendation

    It's recommended to mock a popup window using the page DOM (e.g. using a DIV styled to look like a popup window). Many sites are moving this way to get past popup blockers.

    There are many examples on the Internet. For example using JavaScript to create a Popup, using jQuery API to create a popup jQuery is a JavaScript layer on top of JavaScript and will give you some implicit cross-browser compatibility features.

    You will be able to have scrolling inside the mocked popup using CSS

    div {
    width:150px;
    height:150px;
    overflow:scroll;
    /* etc... */
    }
    

    or to suppress it overflow:hidden;

提交回复
热议问题