QA Graphic

Add Link Check - JQuery

Using Add Link Check to find certain links

There's a cool jQuery trick to check to see if all the hyperlinks on the current page are going to a certain URL. This is useful if you want a quick way to make sure that links are pointing to a Dev environment.

Enable jQuery

if the site isn't using jquery, you'll need to add it, if you don't know it doesn't hurt to run this as it won't break the site (Unless the site is using some bleeding edge jQuery code.)

Open up the Chrome Console and paste the following:

var script = document.createElement("script");
script.setAttribute("src", "[https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js)");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);

You should get back the following:

<script src="[https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js)"></script>

Now run this:

$("a[href*='[company.com](http://company.com/)']").css("color", "orange");

This will highlight any link going to [company.com](http://company.com) to orange. You probably won't see any changes on your site, so change it to something reasonable.

If something did get changed, you should see how many links got changed:

init(213)

 

About

jQuery is the most popular Javascript library on the Internet. Chances are that websites that your testing use it. These posts are all about tips and tricks for QA testing.

Schedule

ThursdayGluten Free
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
Monday Media Monday
TuesdayQA
WednesdayKeyboard Maestro