HighDots Forums  

Re: Javascript - Event Propagation (iframe to enclosed html)

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Javascript - Event Propagation (iframe to enclosed html) in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Stephen Chalmers
 
Posts: n/a

Default Re: Javascript - Event Propagation (iframe to enclosed html) - 05-03-2004 , 03:37 PM






"Wendi" <wenditurner (AT) earthlink (DOT) net> wrote


Quote:
How can i capture an onClick event from within the calling iframe document
(not
using a cookie or something)? Any ideas?

Wendi Turner
wenditurner (AT) earthlink (DOT) net

It still isn't totally clear what you're asking.
I assume you want an onclick event in the parent document to call a function
coded in the iframe's document (sample.htm), and you want the code that
instigates this action to be within the latter.

If so, say you created a link in the parent document (Iframe.htm) like:

<A HREF='#' id='callFrameFunc' >Whatever</A> (or any element with an onclick
event)

Then in sample.htm you would have:

<SCRIPT>
parent.document.getElementById('callFrameFunc').on click=fireClickFunctions;
</SCRIPT>

Alternatively you could simply use the element's onclick event to call a
function in the iframe (sample.htm)

<A HREF='#'
onclick="if(window.frames)window.frames[0].fireClickFunctions();return false">Do
it in the iframe</A>

If you wanted it the other way round (click in iframe calls function in parent),
the syntax in the parent document would be something like:

window.frames[0].document.getElementById('myElement').onclick=loca lFunction;

--
Stephen Chalmers







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.