Click to See Complete Forum and Search --> : JS script that performs a href action
jitseschaafsma
03-13-2003, 09:49 AM
maybe i should refrase my earlier question to my first solution.
Is it possible to write a JS function that performs a link action like <a href="mylink> </a>
Thanks
Jitse
Is this what you mean?
<a href="http://www.w3c.com" onClick="window.location.href=this.href; return false;">W3C</a>
jitseschaafsma
03-13-2003, 10:25 AM
thanks for your reply, but i am not sure.
Let me write my wishes in pseudo code:
<img src="button.gif" onclick=gotolink()>
function gotolink()
{
if (navigation=="A")
<a href="mylink_1">
if (navigation==B)
<<a href="mylink_B">
}
Depending on the value of navigation, clicking on the button brings the user to either mylink_A or mylink_B.
Please support me some more
Jitse
Well, I don't know how you are getting what navigation equals, but here's how to code it...
function gotolink()
{
if (navigation=="A")
{
window.location.href= "yourpage.htm";
}
if (navigation=="B")
{
window.location.href = "yourotherpage.htm";
}
}
Vladdy
03-13-2003, 11:19 AM
or
<a style="background-image:url(button.gif)" href="#" onclick="setHref(this);"></a>
function setHref(link)
{ if(navigation=="a") link.href="mylinkA.html";
if(navigation==b) link.href="mylink1.html";
return true;
}