摘要:核心函数代码:function cIsHTML(str) { // parseHTML 会解析页面中的代码,故放弃此方法实现 //try { &n
核心函数代码:
function cIsHTML(str) {
// parseHTML 会解析页面中的代码,故放弃此方法实现
//try {
// $.parseHTML(str);
// } catch (e) {
// return {
// errno: e.name,
// errmsg: e.message
// };
// }
// return true;
if (/\s?<!doctype html>|(<html\b[^>]*>|<body\b[^>]*>|<x-[^>]+>)+/i.test(str)) {
return true;
}
return {
errno: 'Invalid Html code',
errmsg: 'Invalid Html code'
};
}更多关于javascript删除html标签函数cIsHTML请关注PHP中文网(www.php.cn)其他文章!