Web|web Standard |xhtml is doing recently
idrss Online RSS reader, meet the XHTML1.1 standard, but found a problem, target= "_blank" attribute is no longer supported!
Before XHTML1.0 the transition standard, the target= "_blank" property is always a way to pop up a new window after clicking the link, However, the target attribute is no longer supported after XHTML1.0 stringent standards and XHTML1.1 (this method will not pass the verification of the consortium), that is to say, you can no longer use target= "_blank" to pop up a new window! I don't know why the consortium wants to cancel this standard, and some articles say that it is impolite to pop a new window without permission, without language ... The difference between East and West culture, but after all, the standard in the hands of others, we do not have the right to speak! Lenovo's own wireless standard: The WAPI protocol, more revealing the importance of core technologies and standards!!! Only by mastering the core technology and standards can we protect our own interests ~
Less nonsense, pop-up new window is in line with China's national conditions and user habits, to see how the Xhtml1.0 stringent standards and future versions of the XHTML support to open a new window:
A new rel attribute has been added to the XHTML standard, REL has a number of property values, such as Next, previous, chapter, section, and so on. We're going to use the rel= "external" attribute. Code that was written like this:
<a href= "document.html" target= "_blank" > New window </a> now to write this:
<a href= "document.html" rel= "external" > New Window </a>
This is a method that conforms to the strict standard. And, of course, it has to work with a JavaScript.
The complete code for JavaScript is as follows:
function Externallinks () {
if (!document.getelementsbytagname) return;
var anchors = document.getElementsByTagName ("a");
for (var i=0; i<anchors.length; i++) {
var anchor = Anchors[i];
if (Anchor.getattribute ("href") &&
Anchor.getattribute ("rel") = = "external")
Anchor.target = "_blank";
}
}
Window.onload = Externallinks;
You can save it as a. js file (such as external.js) and call it via an external join method:
<script type= "Text/javascript" src= "External.js" ></script>
This is how you can open a new window.
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.