【发布时间】:2014-04-23 17:08:16
【问题描述】:
我正在尝试创建一个 Chrome 扩展程序,当单击扩展程序按钮时将 CSS 注入页面。
弹出窗口加载正常,但无法注入 CSS。
Manifest.json:
{
"name": "Flat Firemem",
"version": "1.0",
"manifest_version": 2,
"description": "Arranges the page properly in the dump.",
"browser_action": {
"default_icon": "logo.png",
"default_popup": "popup.html"
},
"permissions": ["tabs", "<all_urls>", "file:///*"]
}
popup.html
<!DOCTYPE html>
<html style=''>
<head>
<script src='tester.js'></script>
</head>
<body style="width:400px; border: 2px solid black;background-color:LightGray;">
<div id='message'>Hello..!!</div>
</body>
</html>
Style.css
*
{
float: none !important;
position: static !important;
}
table, tbody, td, tfoot, th, thead, tr
{
display: block !important;
}
tester.js:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null,
{file:"style.css"});
});
如果有人弄清楚出了什么问题,那将是非常有帮助的。
【问题讨论】:
标签: javascript css google-chrome-extension