fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="http://www.fmpq.com/jscss/jquery/2.2.0/jquery.min.js"></script> </head> <body> <script> $(function() { var panything = "[\\w\\W]*?", // 空白 pspace = "[\\x20\\t\\r\\n\\f]", // 标签结尾(whitespace or greater-than) pnameEnd = pspace.replace( "]", ">]" ), // 标签名 // https://html.spec.whatwg.org/multipage/syntax.html#tag-open-state // https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state pname = "[a-z]" + pnameEnd.replace( "[", "[^/\\0" ) + "*", // 空元素 // https://html.spec.whatwg.org/multipage/syntax.html#void-elements pvoidName = "(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|" + "source|track|wbr)(?=" + pnameEnd + ")", // 属性 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 pattrs = "(?:" + pspace + "+[^\\0-\\x20\\x7f-\\x9f=\"'/>]+(?:" + pspace + "*=" + pspace + "*(?:\"" + panything + "\"|'" + panything + "'|" + pnameEnd.replace( "[", "[^" ) + "*(?!/)" + ")|))*" + pspace + "*", // 关闭标签的尾随内容 pcloseTail = "(?:" + pspace + panything + "|)", rspecialHtml = new RegExp( // 自关闭的非空元素: $1–$5 "(<)(?!" + pvoidName + ")(" + pname + ")(" + pattrs + ")(\\/)(>)|" + // 非 HTML容器 (element, comment, 或者 CDATA): $6 "(<(script|style|textarea)" + pattrs + ">" + panything + "<\\/\\7" + pcloseTail + ">|" + "<!--" + panything + "--)", "gi" ), pspecialReplacement = "$1$2$3$5$1$4$2$5$6"; $.htmlPrefilter = function( html ) { return ( html + "" ).replace( rspecialHtml, pspecialReplacement ); }; var htm = '<a /><meta>1516</meta>'; alert($.htmlPrefilter(htm)); alert(htm); }); </script> </body> </html>
运行结果