Google can really access the content in JavaScript

Source: Internet
Author: User
Tags contains

Matt Katz says Google can crawl sites through Rover, which explains Google's access to some JavaScript and Ajax content. But does Google really have access to the content in JavaScript? There are still a lot of webmaster questions. It needs to be emphasized that Google can only access some content in the indexed JavaScript, and that important content in the site should be placed in normal HTML files. What JavaScript content can be retrieved and accessed? We need to do some testing to test different types of JavaScript and Ajax, and then look at Google's index.

In the process of testing we will encounter a problem, Ajax and JavaScript you can do a lot of things, you do not have all the content to test, so you can only test a few basic scripts of the site content for interactive use, after the assembly of the sample code contains the test content, parsing the work is to wait, Until the search engine indexes your content.

 Start a simple document.write method

In JavaScript, there are several basic words that write external content to the site page itself. One of them is the Document.Write method. This method writes a text string directly to the Web page's file.

< BODY >

< script type= "Text/javascript" >

document.write ("Hello, can you read these things?");

</script >

< NoScript >

I guess you can't see.

</noscript >

</body >

When the Document.Write method is used to write content, the search engine crawls the page can be indexed, this is the simplest way. In many cases, however, JavaScript in a Web page is imported into a Web page through an external external JavaScript file, so we have to test the file for the second time.

< BODY >

< script type= "Text/javascript" src= "myjavascripe.js" ></script >

< NoScript >

Can you see it?

</noscript >

</body >

When the Search Engine index test page is not indexed by the link in the code and crawl the contents of the external file, so this seems to imply that the search engine can not read the contents of an external JavaScript file.

Another way: InnerHTML

Another way to write in JavaScript content is to use innerHTML. This property updates the contents of an existing element on a Web page. For example, if you have a paragraph on your site, you can use innerHTML to change the new content in the paragraph. There are two test files that can be done at the same time, first of all, the JavaScript contains the content of the pages crawled by Google, as shown in the figure:

  

The second test file is placed in an external JavaScript file, but the code written in the external JavaScript file is the same, and the final result of the test is that when the script is on the same page, the content of the search engine index is no problem, the content of the external JavaScript file, Search engines are still not indexed.

Test Label Content

After testing the basics, I update the test for some of the more complex content, a common use of JavaScript is to create the label content, the label creation can increase the user experience of the page, and help reduce the length of the page, here, Take the jquery tab and the Ajax tab two tags as the contents of the test file.

jquery script all the content on a page. Then, the code shows and hides the contents of the tab based on the site being clicked. In addition, AJAX tag scripts propagate content in different files, even if viewed in a browser it looks like the contents of a file exist.

The final test results show that the method of jquery tagging can be indexed by search engines, and that all relevant content in the page can be retrieved, which is critical to optimization. However, apart from the AJAX tag index external files, Google is not able to understand the Ajax tag, meaning that all content should be associated with a single page.

Through the above test can be found that the search engine can perform some JavaScript content, but there are still some limitations, the best way to do is to get the search engine crawl content and the basic HTML index, like in a page, or use jquery tag, Spreading a file across several files, rather than Ajax, is the label content. In short, it's easy to get Google to come and ask for your content.

Original article Source: http://www.leadseo.cn/seohangye/seozixun/webmaster starting A5, reprint please keep valid link address, thank you!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.