Home > front end > O: js code identification page title keywords to jump to the specified page?
O: js code identification page title keywords to jump to the specified page?
Time:09-30
This web site source code, may contain both [MingYun young] and [friends live together] multiple keywords,
This jump can only scraping of the page title keywords in the title to jump?
Keywords: MingYun teenager, jump to www.aaa.com/1.html Key words: beautiful sister, jump to www.aaa.com/2.html Keywords: friends living together, jump to www.aaa.com/3.html Other comprehensive keywords, unified jump to www.aaa.com
PC and mobile terminal can be applicable, Thank you,
CodePudding user response:
Var titleStr=source code strings. The match (/& lt; title> (. +) & lt; \/title>/[1]); If (titleStr. IndexOf (" MingYun young ") & gt;=0) { Location. A href="https://bbs.csdn.net/topics/www.aaa.com/1.html"; } else if (titleStr indexOf (" beautiful sister ") & gt;=0) { Location. A href="https://bbs.csdn.net/topics/www.aaa.com/2.html"; } else if (titleStr indexOf (" friends live together ") & gt;=0) { Location. A href="https://bbs.csdn.net/topics/www.aaa.com/3.html"; } else { Location. A href="https://bbs.csdn.net/topics/www.aaa.com"; }
CodePudding user response:
If it is to the current page titl directly using var titleStr=document. The title;