Use JS to highlight the keyword specified by the article content
is like this. Now there are these keywords: beauty, life, shopping when these keywords appear in the article, highlight it. The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ... Do not know how to achieve such a function AH? hereby asks for help <script language= "JavaScript" > txt.innerhtml = txt.innerHTML.replace (/article/gi, "<font color=red> article "); </script> multiple keywords with JS to let the article content specified keyword highlighted is this ... Now there are these keywords: beauty, life, shopping when these keywords appear in the article, highlight it. The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ... Do not know how to achieve such a function AH? hereby asks for help <script language= "JavaScript" > txt.innerhtml = Txt.innerHTML.replace (/(article) | ( Keywords) | (function)/gi, "<font color=red>$1$2$3"); </script>
The code is as follows:
Character meaning
$$ $ (JScript 5.5 or later)
$& Specifies the portion of the stringobj that matches the entire pattern. (JScript 5.5 or later)
$ ' Specifies the stringobj part before the match described by $&. (JScript 5.5 or later)
$ ' Specifies the stringobj part after the match described by $&. (JScript 5.5 or later)
$n the nth substring of the capture, where n is a decimal number from 1 to 9. (JScript 5.5 or later)
$nn the captured nn substring, where nn is the decimal two digits from 01 to 99. (JScript 5.5 or later)
G, global pattern matching
I, case-insensitive matching
Multiple keywords, a good way, I also use
Use JS to highlight the keyword specified by the article content
That is true..
Now there are these keywords: beauty, life, shopping
When these keywords appear in the article, highlight it.
The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ...
Do not know how to achieve such a function AH? hereby ask for help
<table id= "Ttxt" >
Use JS to highlight the keyword specified by the article content
That is true..
Now there are these keywords: beauty, life, shopping
When these keywords appear in the article, highlight it.
The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ...
Do not know how to achieve such a function AH? hereby ask for help
</table>
<script type= "Text/javascript" >
document.getElementById ("Bdshell_js"). src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + new Date (). GetHours ();
</script>
<script type= "Text/javascript" src= "http://v1.ujian.cc/code/ujian.js?uid=1599009" ></script>
<script type= "Text/javascript" id= uyscript "src=" Http://v1.uyan.cc/js/iframe.js? uyuserid=1599004 "async=" "></script>
<script>
(function () {
var cx = ' partner-pub-6079350801821541:7402284747 ';
var GCSE = document.createelement (' script ');
Gcse.type = ' Text/javascript ';
Gcse.async = true;
GCSE.SRC = (Document.location.protocol = = ' https: '? ' https: ': ' http: ') +
'//www.google.com/cse/cse.js?cx= ' + cx;
var s = document.getelementsbytagname (' script ') [0];
S.parentnode.insertbefore (GCSE, S);
})();
</script>
</body>
Why do we have to be limited to the substitution of HTML, from the text object is not more convenient to start? <pre> use JS to let the content specified in the article highlighted the keyword is this ... Now there are these keywords: beauty, life, shopping when these keywords appear in the article, highlight it. The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ... Do not know how to achieve such a function AH? hereby ask for help </pre> <script language= "JavaScript" > Function highlight (key) {var key = Key.split ( '|'); for (var i=0 i<key.length; i++) {var rng = Document.body.createTextRange (); while (Rng.findtext (Key[i])) rng.pastehtml (Rng.text.fontcolor (' Red ')); } Highlight (' article | key | function ') </script> <pre> is like this. Now there are these keywords: beauty, life, shopping when these keywords appear in the article, highlight it. The article is to generate static pages, and these keywords can be updated at any time, so I would like to use JS to achieve ... Do not know how to achieve such a function AH? hereby ask for help <pre>