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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    redirecting all hyperlinks?

    Hi everyone.

    1. I have a page which consists of two iframes. The first one displays an external site, and I'm looking for a way that any link clicked on that iframe will open in the second iframe. Is there any script which can be included in the iframe which will make all links open in iframe 2? Failing that, can anyone think of a way to do this?

    2. Is there any script which allows one to DRAG a link between iframes?

    TIA!

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    1) you can use script on your links like
    Code:
     
    <a href="#" onclick='window.parent.document.getElementById("yourOtherIframe").document.location = "mypage6.html";'>Visit mypage 6</a>
    note: iframes are wierd and there is a special syntax to targetting them for script functions, please use the forum search and locate those many other topics on the same question.
    1b) retargeting all the links on a particular page
    Code:
     
    function retarget(){
        var anchors = document.getElementsByTagName("a");
        for(var a = 0; a < anchors.length; a++){
            anchors[a].onclick=function(){window.parent.document.getElementById("otherframe").document.location = anchors[a].href;};
            anchors[a].href = "#";
        }
    }
    2) no.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mjlorbet View Post
    1) you can use script on your links like
    Code:
     
    <a href="#" onclick='window.parent.document.getElementById("yourOtherIframe").document.location = "mypage6.html";'>Visit mypage 6</a>
    Mjlorbeet, thanks for the help. The problem, unfortunately, is that the site in my first iframe is an external one, I therefor can't append code to it's links, which is the big obstacle here.

    Any further help greatly appreciated!

  • #4
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    yep, the cross-domain stuff will getcha
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender


  •  

    Posting Permissions

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