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;

CodePudding user response:

refer to the second floor sky waves reply:
if it is to the current page titl directly using var titleStr=document. The title;



var titleStr=document. The title; 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";
}



So, right?

CodePudding user response:

No,
The current page titl directly with
Var titleStr=document. The title;
If,,,,,,,,,,,,,,,,,

CodePudding user response:

references 4 floor sky waves reply:
no,
The current page titl directly with
Var titleStr=document. The title;
If,,,,,,,,,,,,,,,,,


PC and mobile terminal can be used?

CodePudding user response:

reference 5 floor lveodj reply:
Quote: refer to 4th floor sky waves reply:

No,
The current page titl directly with
Var titleStr=document. The title;
If,,,,,,,,,,,,,,,,,


PC and mobile terminal can be used?

All applicable
  • Related