By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Basic I-Frames Q

P: n/a
Suppose I have a page, call in parent.html . Inside, there is an iframe,
call it child.html . I want it so that in response to a keyboard event
in either parent or child, child.html will respond in a particular way.

Do I need to use a different set of code for each html page, or can I
reuse the same code?

If the code is different, what are the fundamental differences in code?

How do I make one frame respond to events in a different frame as a
general rule?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <bt************@ID-174912.news.uni-berlin.de>, "Fabian"
<la****@hotmail.com> writes:
Suppose I have a page, call in parent.html . Inside, there is an iframe,
call it child.html . I want it so that in response to a keyboard event
in either parent or child, child.html will respond in a particular way.

Do I need to use a different set of code for each html page, or can I
reuse the same code?
With a well-written function, you can reuse the same code, even use only one
function.
If the code is different, what are the fundamental differences in code?
The references. The parent window has to reference the child, the child window
only has to reference itself.
How do I make one frame respond to events in a different frame as a
general rule?


You add the event handler to the page that you want to trap the event from, and
then change the other page dynamically.

If the function is in child.html, and you have the event handlers working as
you want, simply change the event handlers in parent.html to point to the
function in child.html

parent.frames['IFrameName'].showMe()

And in child.html:

function showMe(){alert('This is in the IFrames page')}

Thats assuming you have the IFrame name="IFrameName"
Pass parameters appropriately.

--
Randy
Jul 20 '05 #2

P: n/a
Fabian wrote:
Suppose I have a page, call in parent.html . Inside, there is an iframe,
call it child.html . I want it so that in response to a keyboard event
in either parent or child, child.html will respond in a particular way.

Do I need to use a different set of code for each html page, or can I
reuse the same code?
You can reuse the same code, provided that both parent.html and
child.html can and do link it. That code must distinguish from
what document it is called for proper references (a function that
is passed the reference to the used object could be sufficient).
Note that even if the code is linked through an external script
file, its data is not persistent while navigating between documents.
How do I make one frame respond to events in a different frame as a
general rule?


AFAIK you cannot do this directly. If events bubble (and not all events
do this), they bubble only upwards, not sideways or downwards. Thus if
the frame is a child of a parent document, for the child should response
to events in the parent document, the parent must execute code that
affects the child somehow since the parent's events do not bubble down
to the child, if they bubble. Same goes for frames within the same
level of the frame hierarchy where one frame should respond to the
events of another, and for different windows.
HTH

PointedEars
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.