I have the below element on my web page:
<a target="_blank" href="http://www.fxs.dev/quote/quote.aspx" onclick="javascript:window.location='http://www.fxs.dev/quote/quote.aspx?partnumber=526-NTE3031';" return="" false;="">Request Delivery Quote</a>
I would like to try and add querystrings to the ‘url’ in the “onclick” attribute of the element.
Is there a jquery function that allows me to do edit just the “URL” part of the onclick event. Or do i just have to write my own custom function to strip and edit the onclick event code?
Thanks in advance for your help 🙂
Strictly speaking, the onclick attribute contains a string that’s interpreted as Javascript code. I’m aware of only two things you can do with this; execute it as Javascript, or edit is as a String. The latter would mean you would have to strip the url from it and edit it manually, I’m afraid.
I don’t quite see the reason to having a
window.location=call as the only thing in the onclick of an anchor tag.. wouldn’t that be what the href attribute is for? That’s also much easier to edit with jQuery, using.attr('href','http://example.com');