How to target to an iFrame?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • helraizer1
    New Member
    • Mar 2007
    • 118

    How to target to an iFrame?

    Hi all,

    I am doing an e-portfolio and as part of which I am saving the documents in pdf format. I have used a frameset with a topFrame and mainFrame.

    There are links to documents in topFrame.html and an iFrame in mainFrame.html. What I was planning on doing was, when the user clicks the links in topFrame the link is opened in the iFrame (named and ID'd "frame" (rather than targetting to 'mainFrame' itself)).

    The only problem is that the iFrame is on a different page to the links, even as part of the frameset. Would it be possible in HTML to target the links to 'frame'? Or should I be looking for a javascript solution?

    Sam
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    i think you have to use javascript for that, have a look at the following simple example, that shows you how to refer to specific frames with javascript:

    [HTML]<html>
    <script type="text/javascript">
    function load_in_iframe( url, frame_ref) {
    frame_ref.locat ion.href = url;
    }
    </script>
    <body>
    <iframe name="test1" src="http://www.google.com" ></iframe>
    <iframe name="test2" src="http://www.thescripts. com"></iframe>
    <a href="#" onclick="load_i n_iframe(frames .test2.location .href,
    frames.test1);" >
    load url of frame 2 to frame 1
    </a>
    </body>
    </html>
    [/HTML]
    kind regards

    Comment

    Working...