Forum Moderators: open

Message Too Old, No Replies

Run function defined in parent window from sub window

         

littlegiant

8:20 pm on Jul 13, 2006 (gmt 0)

10+ Year Member



Greetings,

I'd like to know if it's possible to run a function defined in a parent window from a sub window (new window opened by parent window)?

I've tried using this in the subwindow:

window.opener.document.parentWindowFunction()

...and FireBug keeps telling me that parentWindowFunction() is not a function even though I have no problems running parentWindowFunction() directly from the parent window.

The only way I figured out to run this function is to do this:

window.opener.location = "javascript:parentWindowFunction();

...which seems kind of ugly (and hacky).

Is there a better way?

mikedee

11:48 am on Jul 14, 2006 (gmt 0)

10+ Year Member



I think that the functions become global variables in the WINDOW scope.

Something like opener.parentFunction() will work.

daveVk

11:52 am on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try window.opener.parentWindowFunction() works for me

Dave

littlegiant

3:04 pm on Jul 23, 2006 (gmt 0)

10+ Year Member



Thanks!

window.opener.parentWindowFunction(); does indeed work. I think adding the 'document' property was the thing that was messing it up in my original.

(sorry about the delayed response)