【发布时间】:2014-01-14 17:13:52
【问题描述】:
我是一个尝试创建 chrome 扩展的初学者。在这个扩展中,我想要一个 popup.html 文件,上面有“突出显示”按钮。如果用户点击突出显示页面中的所有单词应该被突出显示。
清单
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs", "activeTab"
]
Popup.html
<!DOCTYPE html>
<html>
<head>
<script src="popup.js"></script>
</head>
<body>
<button id="highlight">Highlight</button>
</body>
</html>
popup.js
window.onload = function(){
document.getElementById('highlight').onclick = highLight;
function = highLight(){
//How can I make all the text highlighted
}
};
如何访问 DOM 以突出显示每个单词?
提前致谢!
【问题讨论】:
-
问题在哪里?
-
如何访问 DOM 以便突出显示每个单词?
-
添加 class= 突出显示并使用 css 自定义。
-
我无权访问 DOM 来执行此操作。我想知道如何使用扩展访问 DOM。
标签: javascript html google-chrome google-chrome-extension