Replace the a link href and title

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The new project approval, the customer detection webpage safety issues, said that the current webpage using “ http://” risk, specify an external link without “ http://” how the whole……

Then I thought with JS replacement string to find for a long time, finally found the final combination, is to use JQ to change the URL, Title can also change, and then use JQ as an external file to reference, avoiding the current webpage “ http://” code; if there are more simple method we hope to share~


 1 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
 2 <script>
 3 $(function(){
 4     $(".forget_link").attr({
 5       "href" : "http://www.w3school.com.cn/jquery/",
 6       "title" : "W3School jQuery tutorial"
 7     });
 8 });
 9 </script>
10 <p><a href="http://www.w3school.com.cn" title="asdfasfd" class="forget_link">W3School.com.cn</a></p>
11 <p>Please move the mouse pointer to the link, or click on the links to view has changed, the values of href and title already set value. </p>

Rookie example:

W3School.com.cn

Please move the mouse pointer to the link, or click on the links to view has changed, the values of href and title already set value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Benson at November 24, 2013 - 4:06 PM