问题
Suppose I have something like this page:
<noscript>You need JS for this page</noscript>
<script>
document.write('you have javascript');
$(function() { /* Some DOM heavy coding */ });
<script>
What will this look like to google? If someone searches google for "you have javascript" will they see my page?
回答1:
The safest answer is: don't rely on it. In particular because you're doing heavy DOM coding.
If the code must be in Google for search purposes then create that part of the HTML on the server and use JavaScript only for interaction. Google's web crawlers are getting smarter but I don't expect them to understand arbitrary JavaScript code.
回答2:
Yes, Google’s Bots Understand Code
How much javascript does Googlebot read
Google Admits GoogleBot can Parse and Execute JavaScript Code on-the-fly
You may find this useful as well: View a Web Page as 'Googlebot'
And for completeness: Google 'googlebot javascript' and these are all on the first page.
回答3:
On my own side, I can confirm GoogleBot executes JavaScript, and according to the IP, it was really it, and not just UA spoofing from a browser.
I learned it today, when I wanted to generate some statistics on the use of AdBlockPlus and the likes, when I saw GoogleBot appearing in the logs, which I was not expecting. Seems he also use JavaScript execution to figure some new URLs to crawl; I mean, if a JavaScript loads a page in an IFRAME with some parameters in the URL, it may first try to load the page without the parameters, then only later try to load the page with the parameters. This may suggest it first execute the JavaScript in a kind of sandbox to see what it do.
来源:https://stackoverflow.com/questions/9980824/can-googlebot-do-basic-javascript