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

    redirect page to a specific link on page

    I need to automatically redirect the browser to a page specified by a link on the current page.

    I need to feed the value of either a
    <div id="myID">mylink</div>
    or the value in an anchor
    <a href="mylink">

    to the function

    redirectTo(){
    elem = document.getElementById("mylink").text;
    window.location = elem;
    }
    which is later used in
    <body onLoad="setTimeout('redirectTo()', 1)">

    BUt it doesn't work...

    I tried
    getElementById("mylink").value
    text
    anchor.href

    nothing works. Where is my problem?
    thanks
    M.

  • #2
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this

    <a id="mylink" href="mylink">http://www.yahoo.com</a>
    <script>
    function redirectTo(){
    elem = document.getElementById("mylink").innerHTML;
    window.location = elem;
    }
    </script>
    Last edited by smalldog; 05-11-2007 at 08:07 AM.
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, that helped!!


  •  

    Posting Permissions

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