Forum Moderators: open
It would look something like this:
<A HREF="http://www.blah.com/" onClick="build_url()">build url</A>
<script language="javascript">
function build_url() {
// add parameters to URL string
}
</script>
For example, I want to add several parameters to the URL string, like:
param1=some_string1
param2=some_string2
param3=some_string3
param4=some_string4
all separated by &.
What I would like to know, can I access the anchor's HREF variable?
Does this have a member name? If so, what is it?
Or do I have to build an entirely new URL from scratch?
And I now notice that after I changed the link to use javascript, MSIE now tries
to block my link with a popup security warning? Is this unavoidable?
<a href='somewhere' onclick=buildurl(this)>GOO</a> //this means what u send this object
function buildurl(newhref)
{newstring='somesite.com?onevariable=onevalue';
newhref.href=newstring;
}
that's all.
All you need is to make a string.
You can do it with javascript variables like
statevariable='good';
statevalue='yes';
{newstring='somesite.com?'+statevariable+'='+statevalue';
and you get somesite.com?good=yes
then change href to it
newhref.href=newstring;
all is simple)
good luck to you
- only happens on your PC, not online
[webmasterworld.com...]