复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ponent(keyword.replace(/\,/g, ' ')).split(/\s+/);
//替换关键字
for (w = 0; w < words.length; w++) {
// 匹配关键词,保留关键词中可以出现的特殊字符
var r = new RegExp("(" + words[w].replace(/[(){}.+*?^$|\\\[\]]/g, "\\$&") + ")", "ig");
temp = temp.replace(r, "<b style='color:Red;'>$1</b>");
}
//恢复HTML标签
for (var i = 0; i < arr.length; i++) {
temp = temp.replace("{[(" + i + ")]}", arr[i]);
}
textbox.innerHTML = temp;
}
highlight("textbox","百度,李彦宏");
</script>
</body>
</html>
