带有mootools的XHTML有效外部链接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带有mootools的XHTML有效外部链接相关的知识,希望对你有一定的参考价值。
W3C no longer include the target attribute of the <a> tag in html 4.0 Strict and XHTML 1.0 Strict document types . To make links open new windows we will have to use javascript, and with mootools it make this task very easy. Just add this snippet to the bottom of your html document and it will look for all external links on your page and add the target attribute to each of the links.
$$('a[href^=http]').each(function(a) { if (window.location.hostname) { var hostname = window.location.hostname.replace("www.", "").toLowerCase(); if (!a.get('href').contains(hostname)) { a.set({ 'target': '_blank' }); } } });
以上是关于带有mootools的XHTML有效外部链接的主要内容,如果未能解决你的问题,请参考以下文章