简体   繁体   English

Chrome扩展程序-以“全屏模式”输入会将页面背景颜色变为黑色

[英]Chrome Extension - Entering in FullScreen Mode turns the page background color to black

I am creating a Chrome Extension that allows the user to view any web page in full screen: 我正在创建一个Chrome扩展程序,该扩展程序允许用户以全屏方式查看任何网页:

manifest.json 的manifest.json

{
   "manifest_version": 2,
   "name": "...",
   "version": "1.0",
   "description": "...",
   "background": {
    "scripts": ["jf.js"]
   },
   "browser_action": {
    "default_icon": "icon.png",
    "default_title": "..."
   },
   "author": "..." ,
   "file_system_provider_capabilities":
  {
    "configurable": false
  },
   "incognito": "spanning",
   "offline_enabled": true,
   "permissions": [
     "tabs",
     "activeTab"
   ],
   "short_name": "..."
}

jf.js jf.js

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.insertCSS(null, {file: "jf.css"});
  chrome.tabs.executeScript({
    code: 'document.body.webkitRequestFullscreen()'
 });
});

jf.css jf.css

body:-webkit-full-screen {
 width: 100%;
 height: 100%;
 overflow: scroll;
}

It works fine but when a page goes into FullScreen Mode through the extension the background color of that same page becomes black, how can I solve that? 它工作正常,但是当页面通过扩展名进入“全屏模式”时,同一页面的背景颜色变为黑色,我该如何解决?

I used the FullScreen API described in: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API in order to do this extension. 为了执行此扩展,我使用了https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API中描述的FullScreen API。

Thank You! 谢谢!

I found the solution I needed to switch the 'document.body.webkitRequestFullscreen()' to 'document.documentElement.webkitRequestFullscreen()' and now it works. 我找到了将'document.body.webkitRequestFullscreen()'切换为'document.documentElement.webkitRequestFullscreen()'所需的解决方案,现在可以使用了。

Thank you! 谢谢!

That might be just a bug from Google. 那可能只是Google的一个错误。 You could try setting the background color of to the color it was before afterwards. 您可以尝试将的背景色设置为之后的颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM