Basic I-Frames Q

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabian

    Basic I-Frames Q

    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!


  • HikksNotAtHome

    #2
    Re: Basic I-Frames Q

    In article <bt2bra$2kp85$1 @ID-174912.news.uni-berlin.de>, "Fabian"
    <lajzar@hotmail .com> writes:
    [color=blue]
    >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?[/color]

    With a well-written function, you can reuse the same code, even use only one
    function.
    [color=blue]
    >If the code is different, what are the fundamental differences in code?[/color]

    The references. The parent window has to reference the child, the child window
    only has to reference itself.
    [color=blue]
    >How do I make one frame respond to events in a different frame as a
    >general rule?[/color]

    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="IFrameNam e"
    Pass parameters appropriately.

    --
    Randy

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Basic I-Frames Q

      Fabian wrote:
      [color=blue]
      > 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?[/color]

      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.
      [color=blue]
      > How do I make one frame respond to events in a different frame as a
      > general rule?[/color]

      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

      Comment

      Working...