Google Scans Javascript for URLs

by Stephen Fluin 2010.05.30

Today I was browsing the Google Webmaster tools, and it notified me that I had a broken link to "/img/.html", which was odd. I checked out the pages that Google reported referring to it, and was confused to see that none of the links on the page lead to this url. I did a scan of my site for this string, and found it hidden in a piece of javascript.

The background was that I have a very simple piece of javascript that allows keyboard navigation of my photos. I was lazy and built it with the following PHP:

if ("$variable"!= "" && event.keyCode == 37) { window.location = "/img/$variable.html"; }

As you can see, when this variable is empty (It is still sent to the browser by the PHP), the javascript check fails and disallows the event. What was odd though was that because PHP was still outputting window.location = "/img/.html";, Google tried to crawl the page, and found that it didn't exist, reporting a broken link.

This level of sophistication is astounding, even though it didn't work. I'm going to need to be more careful in the future with URLs that I put in javascript. Perhaps this has some sort of impact on keywords used in Javascript as well?


permalink