I'm a complete novice, i want to take a text from a "p" tag and put it in another "p" tag so when i click on my extension i see the two texts being displayed. What i'm doing wrong? and how can i avoid similar mistakes in the future?
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"
}
}
Use this HTML for popup: you are having typo mistake 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With