如何使chrome扩展程序全屏显示?

时间:2012-06-26 14:55:07

标签: html css css3 google-chrome-extension

我正在尝试将Chrome扩展程序设置为全屏,但我能做的最大值是半宽。更多的是它只是给我一个底部的滚动条.. 如何让它全屏显示?意思是,Chrome浏览器的整个宽度? 谢谢!

5 个答案:

答案 0 :(得分:10)

chrome.windows.update(windowId, { state: "fullscreen" })

请参阅http://developer.chrome.com/extensions/windows.html#method-update

答案 1 :(得分:2)

在你的扩展“background.js”脚本中:

chrome.app.runtime.onLaunched.addListener(function (launchData) {
  chrome.app.window.create(
    // Url
    '/editor.html',
    // CreateWindowOptions
    {
            'width': 400,
            'height': 500
    },
    // Callback
    function(win) {
        win.contentWindow.launchData = launchData;
        win.maximize();
        win.show();
    });
});

答案 2 :(得分:1)

您是否尝试过fullScreen API

答案 3 :(得分:1)

addEventListener("click", function() {
    var
          el = document.documentElement
        , rfs =
               el.requestFullScreen
            || el.webkitRequestFullScreen
            || el.mozRequestFullScreen
    ;
    rfs.call(el);
});

如此post

所示

答案 4 :(得分:0)

适用于所有浏览器的网页,包括msRequestFullscreen

addEventListener("click", function () {
    var
          el = document.documentElement
        , rfs =
               el.requestFullScreen
            || el.webkitRequestFullScreen
            || el.mozRequestFullScreen
            || el.msRequestFullscreen
    ;
    if (rfs) { rfs.call(el); } else { console.log('fullscreen api not supported');}
});