css 如何使Chrome扩展在全屏?

qij5mzcb  于 2022-11-19  发布在  其他
关注(0)|答案(5)|浏览(170)

我试图使chrome扩展是在全屏,但最大的我可以做的是一半的宽度。然后,它只是给予我一个滚动条在底部..我怎么才能使它在全屏?意思是,整个宽度的chrome浏览器?谢谢!

hivapdat

hivapdat1#

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

请访问https://developer.chrome.com/docs/extensions/reference/windows/#method-update

jdzmm42g

jdzmm42g2#

在您的扩展“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();
    });
});
qxsslcnc

qxsslcnc4#

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

post所示

z18hc3ub

z18hc3ub5#

用于所有浏览器(包括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');}
});

相关问题