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 Coder
    Join Date
    Oct 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Runtimes change <A Href=****>

    Hi All:
    Is any way that I can change the <A href=http://www.yahoo.com> to <A href=http://www.google.com> at runtimes in Javascript. Example using onload()


    Example:
    <HTML>

    <Head>
    <Script Language="JavaScript1.1">
    function change()
    {
    ????????????????????????
    }
    </Script>
    </Head>

    <BODY onload="change();">
    <A href=http://www.yahoo.com> GO </>
    </BODY>

    </HTML>

  • #2
    New Coder
    Join Date
    Mar 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Indeed!

    Code:
    <script language="javascript" type="text/javascript">
    <!--
    
    function change(){
    if(document.getElementById){
       a=document.getElementById("mylink");
       a.setAttribute("href","http://www.simondvorak.com");
    }
    }
    window.onload=change;
    //-->
    </script>
    ...
    <body>
    <a href="http://www.msn.com" id="mylink">Link</a>
    Hope that helps!

    Cheers,
    Simon

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just like so...

    Code:
    window.onload
    {
    	document.getElementById("element_name").setAttribute("href", "http://www.google.com", 0);
    }


  •  

    Posting Permissions

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