Apa*_*rix 2 html javascript google-chrome-extension
我是一个完整的新手,我想从"p"标签中取出一个文本并将其放在另一个"p"标签中,这样当我点击我的扩展名时,我会看到正在显示的两个文本.我做错了什么?我怎样才能避免将来出现类似的错误?
popup.html:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" scr= "popup.js"></script>
</head>
<body>
<p id="firstText">this is the text to be repeated</p>
<p id= "secondText"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
popup.js:
document.addEventListener('DOMContentLoaded', function () {
var test= document.getElementById("firstText").innerHTML;
document.getElementById("secondText").innerHTML=test;
});
Run Code Online (Sandbox Code Playgroud)
manifest.json的:
{
"manifest_version": 2,
"name": "test",
"description": "useless",
"version": "1.0",
"background": {
"scripts": [ "popup.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["popup.js"]
}
],
"permissions": [
"activeTab","tabs", "http://*/*"
],
"browser_action": {
"default_popup": "popup.html"
}
}
Run Code Online (Sandbox Code Playgroud)
使用此HTML进行弹出:您输入错字 src
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src= "popup.js"></script>
</head>
<body>
<p id="firstText">this is the text to be repeated</p>
<p id= "secondText"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3873 次 |
最近记录: |