...

View Full Version : Runtimes change <A Href=****>



owen_yuen
06-08-2004, 04:12 PM
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>

sidvorak
06-08-2004, 05:02 PM
Indeed!



<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

jbot
06-08-2004, 05:02 PM
just like so...


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

:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum