I get this javascript error message
Error: a.getAttribute("rel") is null
on these lines of code
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
any ideas how do I sort it out?
Thanks.
Before using
a.getAttribute("rel")like you are doing :You should test if it’s not null (or not “falsy”) :
With the first portion of condition I added at the beginning of the
ifexpression, the second (and the ones after) portion of the condition will be evaluated only ifa.getAttribute("rel")is truthy — i.e. the won’t be evaluated whena.getAttribute("rel")isnull.