Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a Function in another window

Status
Not open for further replies.

fpgiv

Programmer
Oct 1, 2003
91
US
Hi,
I have a main window that calls a pop-up window. I want to be able to reference a javascript function in the main window from the popup. Is this doable?
Thanks!
 
Code:
parent.functionName();
or possibly
Code:
opener.functionName();

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Thanks, but I was mistaken. The function that calls the function we need to reference is in a .js file--not a popup window. Is it still able to be referenced?
 
If the .js file is on the parent or opener, then it can be referenced.

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
/* I want to be able to reference a javascript function in the main window from the popup. Is this doable? */

Yes, it is possible if you're opening a file that already already exists, such as blah.html, with window.open().

From the child window, you can call a function such as parentWindowFunction() from the parent by using something like this in the child and using the "opener" property:

self.opener.parentWindowFunction();

This works in IE6 and Opera 7, I haven't tested it with any other browsers.

...........................................

I've been trying to figure out how to create script in a new window that is written on the fly but not having much luck. So, I'm opening an existing window that already contains the script.

For every problem, there's a solution and every solution brings it's own set of problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top