...

View Full Version : redirect page to a specific link on page



mtomko
05-11-2007, 06:32 AM
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.

smalldog
05-11-2007, 07:58 AM
try this

<a id="mylink" href="mylink">http://www.yahoo.com</a>
<script>
function redirectTo(){
elem = document.getElementById("mylink").innerHTML;
window.location = elem;
}
</script>

mtomko
05-11-2007, 09:05 AM
thanks, that helped!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum