Jump to content

change href and add onclick all in one line..


antonyfal

Recommended Posts

I'm changing all the links on my site from:

//example current link is:
<a href="http://www.xxxxx.com/subfolder/somefile.php/?someoption&somethingelse">click</a>

//If you put the mouse over the link it is displayed in the address bar. i don't want site users to see this links.

//i want to make something like this:

<a href="javascript:void(0);" onClick="openUrl(\"http://www.xxxxx.com/subfolder/somefile.php/?someoption&somethingelse\",_self);">click</a>

// so now the user only see the   javasript:void(0);  and not the link.


 

but my code is not working, and i have to many links and pages to make a javascript function for redirecting the url onclick for every link.

is there a universal function to achieve the goal that i want?

 

Ok i got it to work like this:

 

<a href="javascript:void(0);" onClick="javascript:q=(document.location.href);void(open('http://www.xxxxx.com/subfolder/somefile.php/?someoption&somethingelse?url='+escape(q),'_self',''));">click</a>

 

if anyone knows a better way? please post here.

also it seems that the "q" can remain "q" regardles of the amount of links on a page.. It doesnt have to change to q for one link, z for another b for another etc etc etc..

OK!! sorry not solved. This code only works on some links.. Is there a better way to have:

 

onclick="openUrl('http://xxx.com/subfolder/index.php/?someoption.html');

 

i just basically want to move the href link into the onclick and the href must = javascript:void(0); Can anyone do this is please?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.