Home >Web Front-end >JS Tutorial >How to determine the source of spiders using JavaScript script_javascript skills
The JS script introduced today is written in the onload of the body. That is, the judgment is made when the page is loaded. The code is as follows:
body {onload:expression( if(window.name!="Yang"){ var str1 = document.referrer; str1 = str1.toLowerCase(); var str6 = 'google.'; var str7 = 'baidu.'; var str4 = 'yahoo.'; var str8 = 'youdao.'; var str9 = 'sogou.'; var str5 = 'soso.'; if(str1.indexOf(str7)>0 || str1.indexOf(str6)>0 || str1.indexOf(str4)>0 || str1.indexOf(str3)>0 || str1.indexOf(str8)>0 || str1.indexOf(str9) >0 || str1.indexOf(str5)>0 && "zh-cn"==navigator.systemLanguage) { self.location='http://www.abc.com/'; window.name="Yang"; } } );}
This JS method of determining the source of spiders is not easy to use. Especially when more spider sources need to be determined, it is more troublesome to write code.