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?

 

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.