-
-
Save 0x2f0713/1f8e32ae001a9635be5461b423a47d89 to your computer and use it in GitHub Desktop.
Execute script after click in popup.html (chrome extension) http://stackoverflow.com/questions/20764517/execute-script-after-click-in-popup-html-chrome-extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert('hello ' + document.location.href); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "Click to execute", | |
"description": "Execute script after click in popup.html (chrome extension) http://stackoverflow.com/questions/20764517/execute-script-after-click-in-popup-html-chrome-extension.", | |
"version": "1.0", | |
"icons": { | |
"48": "icon.png" | |
}, | |
"permissions": [ | |
"tabs", "<all_urls>" | |
], | |
"browser_action": { | |
"default_icon": "icon.png", | |
"default_popup": "popup.html" | |
}, | |
"background": { | |
"scripts": ["background.js"], | |
"persistent": false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body style="width: 300px"> | |
Open <a href="http://stackoverflow.com" target="_blank">this page</a> and then | |
<button id="clickme">click me</button> | |
<script type="text/javascript" src="popup.js"></script> | |
</body> | |
</html> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var app = chrome.runtime.getBackgroundPage(); | |
function hello() { | |
chrome.tabs.executeScript({ | |
file: 'alert.js' | |
}); | |
} | |
document.getElementById('clickme').addEventListener('click', hello); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment