Yet another Javascript and iframe question........

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dany P. Wu

    Yet another Javascript and iframe question........

    Hi everyone,

    I am trying to create a site with pages containing iframes. This is the
    first time I've used inline frames and am still struggling with the concept.

    This site will have 10 pages and so far I have created 20 files, each page
    having to use a pair of files. One file for the actual page, and one file
    for the content of the inline frame.

    It sounds bloody silly to me but then again I am only a beginner at web
    devel. The tag I use for these pages look a bit like this:

    <iframe name="frame" height="409" width="580" border="0" frameborder="0"
    src="sub_contac t.html" scrolling="auto "> Sorry, we're having
    problems</iframe>

    Is there any way I can use Javascript to detect what button/link has just
    been clicked, and assign the appropriate value to the "src" variable? Then
    perhaps I can only use one file for the actual page, and 10 files for each
    content of the inline frames?

    I hope this question makes some sense. I come from a programming background
    but never web apps or anything remotely to do with dynamic web pages. Never
    touched Javascript either!

    Any suggestions or pointers (no puns intended) would be immensely
    appreciated.

    Cheers,
    Dany.


  • Martin Honnen

    #2
    Re: Yet another Javascript and iframe question....... .



    Dany P. Wu wrote:[color=blue]
    > I am trying to create a site with pages containing iframes. This is the
    > first time I've used inline frames and am still struggling with the concept.
    >
    > This site will have 10 pages and so far I have created 20 files, each page
    > having to use a pair of files. One file for the actual page, and one file
    > for the content of the inline frame.
    >
    > It sounds bloody silly to me but then again I am only a beginner at web
    > devel. The tag I use for these pages look a bit like this:
    >
    > <iframe name="frame" height="409" width="580" border="0" frameborder="0"
    > src="sub_contac t.html" scrolling="auto "> Sorry, we're having
    > problems</iframe>
    >
    > Is there any way I can use Javascript to detect what button/link has just
    > been clicked, and assign the appropriate value to the "src" variable? Then
    > perhaps I can only use one file for the actual page, and 10 files for each
    > content of the inline frames?[/color]

    Learn HTML, you can use a link with a target attribute set to the frame
    name, thus if you have
    <iframe name="iframeNam e"
    then you use links alike
    <a target="iframeN ame" href="whatever. html">
    to load pages into the iframe. No need for JavaScript
    --

    Martin Honnen


    Comment

    • Dany P. Wu

      #3
      Re: Yet another Javascript and iframe question....... .

      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:3fb76000$1 @olaf.komtel.ne t...[color=blue]
      >
      > Learn HTML, you can use a link with a target attribute set to the frame
      > name, thus if you have
      > <iframe name="iframeNam e"
      > then you use links alike
      > <a target="iframeN ame" href="whatever. html">
      > to load pages into the iframe. No need for JavaScript[/color]

      Hi Martin,

      Thanks for the reply but that's not quite what I wanted. My apologies for
      not explaining properly.

      I realised you can create a link with an iframe as the target. What I was
      after is a link on a particular page (page1), which loads another page
      (page2) with the appropriate content displayed in an iframe in page2. The
      content of the iframe on page two is dependent on the button clicked on
      page1.

      Is this possible?

      Cheers,
      Dany.


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Yet another Javascript and iframe question....... .

        Dany P. Wu wrote:
        [color=blue]
        > What I was after is a link on a particular page (page1), which loads
        > another page (page2) with the appropriate content displayed in an iframe
        > in page2. The content of the iframe on page two is dependent on the
        > button clicked on page1.
        >
        > Is this possible?[/color]

        Unless you are not violating the Same Origin Policy, it is. All you need
        is to follow the DOM tree down to the target IFrame object using the
        frames[...] collection.


        HTH

        PointedEars

        Comment

        Working...