Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    target iframe link using javascript

    Hi! I have 3 iframes in one page...One of the iframes contains the menu and I want the other 2 iframes to change once the link in the menu is clicked. I tried using this code

    Code:
    <script language="javascript"> 
    function loadTwo(iframe1URL, iframe2URL) 
    { 
    parent.FRAME1.location.href=iframe1URL 
    parent.FRAME2.location.href=iframe2URL 
    } 
    </script>
    but it won't work if the link is coming from another iframe. Please help me. I've been stuck with this problem for hours and hours already!

  • #2
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Cool

    I've several iFrames on my site:

    http://arctic.ithium.net/

    ...that do all sorts of cross-linking tasks.

    View-source to find your answer.
    <div> - putting your mind in a box since 1997

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    ArticFox..just encase you didnt know..when i go to your site it throws an error in my javascript console...though, i saw your site said under construction..so you probly allready know, but i was just pointing it out just encase

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    You may:

    1.- use a simple HTML action

    <a href="page1.html" target="iframe">PAGE1</a>
    <a href="page2.html" target="iframe">PAGE2</a>
    ...
    <iframe name="iframe" src="page0.html"></iframe>

    2.- or

    top.frames['iframe'].location.href = 'page1.html';
    top.frames['iframe'].location.href = 'page2.html';

    3.- or

    document.getElementById('iframe').setAttribute('src',''page1.html');
    document.getElementById('iframe').setAttribute('src',''page2.html');

    but use id for iframe
    <iframe id="iframe" src="page0.html"></iframe>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Target all links in an iFrame

    Is there a way to target all the links in an iFrame to a new window even if the page that is being loaded into the frame is an external source which can not be modified.

    Example: I creat an iFrame with www.sony.com info in it. Can I have all the links open in a new window rather than refresh the iFrame?

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Quote Originally Posted by hurrikane
    Is there a way to target all the links in an iFrame to a new window even if the page that is being loaded into the frame is an external source which can not be modified.

    Example: I creat an iFrame with www.sony.com info in it. Can I have all the links open in a new window rather than refresh the iFrame?
    Nope. Can't do it.

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #7
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor View Post
    You may:

    1.- use a simple HTML action

    <a href="page1.html" target="iframe">PAGE1</a>
    <a href="page2.html" target="iframe">PAGE2</a>
    ...
    <iframe name="iframe" src="page0.html"></iframe>

    2.- or

    top.frames['iframe'].location.href = 'page1.html';
    top.frames['iframe'].location.href = 'page2.html';

    3.- or

    document.getElementById('iframe').setAttribute('src',''page1.html');
    document.getElementById('iframe').setAttribute('src',''page2.html');

    but use id for iframe
    <iframe id="iframe" src="page0.html"></iframe>
    I know this is an extremely old thread, but this is exactly what I needed (thanks ). Although, to save the next new guy like me some time, there's an extra tick mark you don't need before 'page1.html' and 'page2.html' in option 3.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •