Tag Seo optimization details

Source: Internet
Author: User

If you need to open the link in a new window, we use taget = "_ blank" on a, but many people do not know that this is not in line with W3C specifications, the error message "there is no attribute target for this element (in this html Version)" is prompted when strict doctype (xhtml1-strict.dtd) Verification is used.

Therefore, the taget = "_ blank" is basically not displayed in many foreign articles ".The alternative solution is to use the newly added tag rel in html4.0 to indicate the relationship between the link and the page containing the link, and the target of the Link Opening. Rel has many attribute values, such as next, previous, chapter, and section, and nofollow, which is used to reject crawling down by search engine spider.(This is very important. In Wordpress, almost all user name links in comments are added with rel = nofollow, so it is futile to add comments to the blog to add external links). Now we want to use the rel = "external" attribute to indicate that the link will be opened in a new window. Of course, this is only a method that complies with the strict standard, but does not really enable the link in the new window. It also requires support from the scripting script.

Train of Thought: After loading the page, add target = "_ blank" To Rel containing the external a tag through Js. The jquery method is provided below,CodeAs follows:

<SCRIPT type = "text/JavaScript">Jquery (Function($ ){//External and target = "_ blank"$ ("A [rel * = External]"). ATTR ("target", "_ blank");});</SCRIPT>

The above is just the implementation method of jquery and also the method used by Benbo. the native method of js is as follows:

<SCRIPT type = "text/JavaScript"> Function  Externallinks (){  If (! Document. getelementsbytagname) Return  ;  VaR Anchors = Document. getelementsbytagname ("" );  For ( VaR I = 0; I <anchors. length; I ++ ){  VaR Anchor = Anchors;  If (Anchor. getattribute ("href ")&& Anchor. getattribute ("rel ") = "External") anchor.tar get = "_ Blank" ;} Window. onload =Externallinks; </SCRIPT>

 

Related Article

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.