如何在Google Chrome浏览器中没有滚动条的情况下使用window.open [英] How to do window.open with no scrollbars in Google Chrome

查看:412
本文介绍了如何在Google Chrome浏览器中没有滚动条的情况下使用window.open的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在Firefox,IE和Opera中打开不带滚动条的新窗口

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

Google Chrome 中,新窗口仍然有滚动条。
任何想法使它工作?

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

推荐答案

这种风格应该做的诀窍,将其添加到打开的窗口文档:

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


body{ overflow-x:hidden;overflow-y:hidden; }

这篇关于如何在Google Chrome浏览器中没有滚动条的情况下使用window.open的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆