Sneaky JavaScript redirects When Googlebot indexes a page containing JavaScript, it will index that page but it cannot follow or index any links hidden in the JavaScript itself. Use of JavaScript is an entirely legitimate web practice. However, the use of JavaScript with the intent to deceive search engines is not. For instance, placing different text in JavaScript than in a no-script tag violates our
Webmaster Guidelines because it displays different content for users (who see the JavaScript-based text) than for search engines (which see the no-script-based text). Along those lines, it violates the Webmaster Guidelines to embed a link in JavaScript that redirects the user to a different page with the intent to show the user a different page from the one that the search engine sees. When a redirect link is embedded in JavaScript, the search engine indexes the original page rather than following the link, whereas users are taken to the redirect target. Like cloaking, this practice is deceptive because it displays different content to users and to Googlebot and can take a visitor somewhere other than where they intended to go.
Note that placement of links within JavaScript is alone not deceptive. When examining JavaScript on your site to make sure that your site adheres to our guidelines, consider the intent.
Keep in mind that since search engines generally can't access the contents of JavaScript, legitimate links within JavaScript will probably be inaccessible to them (as well as to visitors without JavaScript-enabled browsers). You might instead keep links outside JavaScript or replicate them in a no-script tag.