Reputation: 1093
I have popup.html I want to load different html page in extension when user click href. Example user will enter username and password and if they are correct login.html redirect to content.
Tried this:
window.onload=function(){
$( '#Login' ).click(function() {
alert('test');
chrome.browserAction.setPopup({
popup:"login.html"
});
});
}
Upvotes: 5
Views: 4922
Reputation: 1
Try this
<a href="another-page.html"><button id="add-button">Go to another popup</button></a>
Upvotes: 0
Reputation: 10949
To change the popup html page you can use
chrome.browserAction.setPopup
more detailes on this page http://developer.chrome.com/extensions/browserAction.html
you can do something like this:
in html:
<a onclick="changePopup();" href="#"> change popup</a>
in js:
function changePopup(){
chrome.browserAction.setPopup({
popup:"second_page.html"
});
}
You didn't specified where is the link placed? in the popup page or in an html page, so I assumed the linked is placed in popup html page.
If the link is placed outside extension, you should use Content Scripts https://developer.chrome.com/extensions/content_scripts.html
UPDATE: You should put the java-script file in your manifest.json using background pages or event pages depending on what you need.
Here you can find more info:
https://developer.chrome.com/extensions/background_pages.html
http://developer.chrome.com/extensions/event_pages.html
....
"background": {
"scripts": ["background.js"]
},
....
If you loaded the javscript file from your html page using the <script>
tag , you should use the Message passing api : http://developer.chrome.com/extensions/messaging.html to interact with your html.
Upvotes: 2