Is it possible to call function on a page?
For example I have a page called help.html and that page has a function called help(id).
Can I call this function and pass the id to it?
Thanks in advance
Is it possible to call function on a page?
For example I have a page called help.html and that page has a function called help(id).
Can I call this function and pass the id to it?
Thanks in advance
I am not sure I understand your question, but it will be better create a separate js-file. Here is an example (I use jQuery):
popup.html:
<html>
<head>
<script src="jquery-2.0.3.js"></script>
<script src="popup.js"></script>
</head>
<body>
<input id="amount" type="text" />
<input id="addAmount" type="submit" value="Add" />
</body>
</html>
popup.js:
$(function() {
$('#addAmount').click(function() {
alert('hi');
});
});
You can if the page is opened and loaded, and you have a reference to its window
object. One way to make sure both things are true is to have code on your help window call a function on your background page when it is ready, passing a reference to itself. So on your help window you can have something like:
chrome.extension.getBackgroundPage().helpWindowLoaded(window);
And on your background page:
function helpWindowLoaded(helpWindow) {
helpWindow.help(id);
}