其实只是在固定的位置,把需要查找的关键字,设置下样式。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml/DTD/xhtml1-transitonal.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>高亮文字</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <mce:script type="text/javascript"><!-- function highLight(ele,keys){ var reg = new RegExp("(" + keys.replace(/,/,"|") + ")","g"); ele.innerHTML = ele.innerHTML.replace(reg,"<font color=/"red/";font=/"bold/">$1</font>"); } window.onload = function(){ highLight(document.getElementsByTagName("p")[0],"xujie"); } // --></mce:script> </head> <body> <p>why xujie xuqing xuwen</p> </body> </html>