Click to See Complete Forum and Search --> : Call a javascript-function in a different frame


AStromer
September 9th, 2002, 02:52 AM
I have a window, two frames in it (Frame1, Frame2)
Frame1 is a window where I can put all my javascript-code into.
Frame2 calls simple HTML-Files with now javascript in it.
Now I have a link in Frame2 goes to another simple HTML-File but I want to process that call before it goes to that HTML-File. I thought I can change the links in the simple HTML-Files in Frame 2 to something like
<a href='javascript:parent.Frame1.document.MyLinkProcessFunction(1,2,3)'>Click the link</a>
but with that link I can't call a function in Frame1.

Does anyone know the correct cross-frame function-call or isn't this possible at all ?

Thx

dgobrien
September 9th, 2002, 11:21 AM
I do this all the time. Possibly your problem is using an <a> tag to call the function (the href should be a URL or anchor). Try the same thing in a click handler:

...onclick="top.frames('myframe').myfunc();"

dgobrien
September 9th, 2002, 12:31 PM
My apologies: the <a> tag will execute the javascript just fine. Nevertheless, my remaining comments stand.

ShawnDev
September 9th, 2002, 06:56 PM
But it is not proper form and should be avoided (IMO). It might be that future versions of Javascript will not call functions from the href attribute.

dgobrien
September 10th, 2002, 07:05 AM
hear, hear!

AStromer
September 10th, 2002, 10:45 AM
it works it works :D

Thx.