What I'm trying to do is find all of the links on a page that contain https and if they do, do something. However, when I run this in Chrome using console, I get a Type Error: Cannot call method 'indexOf' of null. I've read on SO that if a value is returned as undefined, then it breaks the function. So I'm wondering how do I ignore https that do not have a value for onclick? (btw, I'm slowly learning javascript/jquery). Thanks
$("a[href*='https:']").each(function(){
var blah = $(this).attr('onclick');
console.log(blah);
if(blah.indexOf('_gaq') === 0){
console.log('contains gaq');
}
});