[Javascript] Referencing javascript functions in other windows
Matt Barton
javascript at mattbarton.org
Wed Jan 21 10:12:37 CST 2004
Hi,
I'm having some difficulty access some javascript functions which are
declared in a popup object (i.e. created using the createPopup method.
I have a window which creates and shows a popup, with the content for the
popup being read from a file and inserted into the popup like this:
<IE:Download ID=dwn STYLE="behavior:url(#default#download)" />
<SCRIPT>
var intPopupWidth = 300;
function onBodyDone(src) {
oPopup.document.write(src);
}
function showPopup() {
oPopup.show(0, 0, intPopupWidth, 300, document.body);
}
var oPopup = window.createPopup();
dwn.startDownload("popup_source.html",onBodyDone);
</SCRIPT>
<img src="menu.gif" onClick="showPopup ();">
Now: inside functions in the popup itself I can reference variables from the
parent window and call functions like this:
// ----
function fMakeWider (intDX) {
window.parent.intPopupWidth += intDX;
window.parent.oPopup.hide();
window.parent.oPopup.show (0, 0, window.parent.intPopupWidth, 300,
window.parent.document.body);
}
// ----
OK? So now what I'm wanting to do is call a function which is declared in
the popup from the parent window.
// ----
function fGetDataFromPopup () {
var someData = {reference to popup window goes here}.fGetSomeData();
}
// ----
I've tried a few different references to the popup window (including oPopup,
oPopup.document) but everythign I've tried gives a 'Yada, yada, yada is null
or not an object'.
Any ideas anyone? I'd be eternally greateful...
Matt
More information about the Javascript
mailing list