2013-09-25 3 views
2

전 초급자입니다. "p"태그에서 텍스트를 가져 와서 다른 "p"태그에 넣으려고합니다. 그래서 내 확장 프로그램을 클릭하면 두 개의 텍스트가 표시됩니다. 표시됩니다. 내가 뭘 잘못하고있어? 앞으로 어떻게 비슷한 실수를 피할 수 있을까요?크롬 확장 기능 변경 popup.html 텍스트

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" 
    } 
} 
+6

정확한 복사/붙여 넣기의 경우 ''에 오타가 있습니다. 'scr' 대신'src'를 읽어야합니다. –

+0

@ChrisP 너무 당황 스럽네. 도와 줘서 고마워! – Apastrix

답변

4

사용 팝업이 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> 
+0

sublimetext2를 사용하고 있습니다. 인터넷을 검색하고 코드를 변경하는 데 보냈습니다. Js ^^ 전에 DOM을로드하려고 jquery 함수를 시도해 보았습니다. ^^ "정말 감사합니다! 나는 당신을 투표하는 데 충분한 명성이 없다. 그러나 나는 그것에 복귀 할 것이다. =) – Apastrix