Once you have access to the current URL, you want to find this element and replace CURRENTPAGE.html. To do this, you will need to somehow select the item. Let him give him an ID:
<a id="myLink" href="http://reddit.com/submit?url=CURRENTPAGE.html"></a>
Now we can capture the link like this:
var link = document.getElement('myLink');
Return the URL again and give it the best variable name:
var url = window.location.href;
Now update the HREF link attribute:
link.href = link.href.replace('CURRENTPAGE.html', url);
What is it!
source share