[英]Chrome extension changing popup.html text
我是一個完整的新手,我想從“ 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>
popup.js:
document.addEventListener('DOMContentLoaded', function () {
var test= document.getElementById("firstText").innerHTML;
document.getElementById("secondText").innerHTML=test;
});
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"
}
}
使用此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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.