/*** @author Hechen*/var gs = {/** รับความกว้างของหน้าจอ **/ScreenWidth: function () {return window.screen.width; }, / *** รับความสูงของหน้าจอ ** / screenHeight: function () {return window.screen.height; }, / ** รับเบราว์เซอร์ *** / เรียกดู: function () {var browser = {}; var useragent = navigator.useragent.toLowerCase (); var s; (s = useragent.match (/msie ([/d.like+ )/))? browser.ie = s [1]: (s = useragent.match (/firefox // ([/d.]+)/))? เบราว์เซอร์. firefox = s [1]: (s = useragent.match (/chrome // ([/d.]+)/))? เบราว์เซอร์. chrome = s [1]: (s = useragent.match (/opera. ([/d.]+)/))? browser.opera = s [1]: (s = useragent.match (/เวอร์ชัน // ([/d.]+).*Safari/))? เบราว์เซอร์ Safari = S [1]: 0; var version = ""; if (browser.ie) {version = 'ie' + browser.ie; } else {if (browser.firefox) {version = 'firefox' + browser.firefox; } else {if (browser.chrome) {version = 'Chrome' + browser.chrome; } else {if (browser.opera) {version = 'opera' + browser.opera; } else {if (browser.safari) {version = 'safari' + browser.safari; } else {version = 'unknown browser'; }}}} เวอร์ชันส่งคืน; }, / ** รับระบบปฏิบัติการ *** / clientos: function () {var suseragent = navigator.useragent; var iswin = (navigator.platform == "win32") || (navigator.platform == "windows"); var ismac = (navigator.platform == "mac68k") || (navigator.platform == "macppc") || (navigator.platform == "Macintosh") || (navigator.platform == "Macintel"); ถ้า (ISMAC) กลับ "MAC"; var isunix = (navigator.platform == "x11") &&! iswin &&! ismac; ถ้า (isunix) กลับ "unix"; var islinux = (string (navigator.platform) .indexof ("linux")> -1); ถ้า (islinux) ส่งคืน "linux"; if (iswin) {var iswin2k = suseragent.indexof ("windows nt 5.0")> -1 || suseragent.indexof ("Windows 2000")> -1; ถ้า (iswin2k) กลับ "win2000"; var iswinxp = suseragent.indexof ("windows nt 5.1")> -1 || suseragent.indexof ("windows xp")> -1; ถ้า (iswinxp) กลับ "winxp"; var iswin2003 = suseragent.indexof ("windows nt 5.2")> -1 || suseragent.indexof ("windows nt 5.2")> -1; ถ้า (ISWIN2003) กลับ "Win2003"; var iswinvista = suseragent.indexof ("windows nt 6.0")> -1 || suseragent.indexof ("Windows Vista")> -1; ถ้า (Iswinvista) กลับ "Winvista"; var iswin7 = suseragent.indexof ("windows nt 6.1")> -1 || suseragent.indexof ("windows 7")> -1; ถ้า (iswin7) กลับ "win7"; } return "อื่น ๆ "; }, / **** รับรหัสไคลเอนต์ **** / clientId: ฟังก์ชั่น (ชื่อ) {var cookies = document.cookie.split (";"); var value = ""; สำหรับ (var i = 0; i <cookies.length; i ++) {var temp = คุกกี้ [i] .split ("="); var tempvalue = temp [0] .replace (/(^/s*) | (/s*$)/g, ""); if (tempValue == ชื่อ) {value = Unsescape (temp [1]); หยุดพัก; }} ค่าส่งคืน; }, / **** รับรหัสผลิตภัณฑ์ **** / searchGid: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.replace (/-/d+-/, ฟังก์ชั่น (a, b, c) {ถ้า (a! = undefined && a! = "" && a.length> 2) {value = a.substring (1, a.length-1); } ค่าส่งคืน; }, / **** รับคีย์เวิร์ดค้นหาไซต์ **** / searchKey: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.replace (/[[roven.*/, function (a, b, c) {ถ้า (a! = undefined && a! = "" && a.length> 1) {value = a.substring (1);}}); } ค่าส่งคืน; }, / ** รับหมายเลขการค้นหาหมวดหมู่ผลิตภัณฑ์ ** / searchCategory: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.replace (/-/d+/, ฟังก์ชั่น (a, b, c) {ถ้า (a! = undefined && a! = "" && a.length> 1) {value = a.substring (1);}}); } ค่าส่งคืน; }, / **** การค้นหานอกสถานที่ Google baidu ***** / searchsite: ฟังก์ชั่น (ประเภท) {var referrer = document.referRer; if (referrer! = undefined && referrer! = "") {ถ้า ("google" == ประเภท) {url.replace (regexp ใหม่ ("(?:^|/? | &) q = ([^&]*) (?: & | $)") A.SubString (A.Indexof ("=") + 1, A.Length - 1); } ถ้า ("baidu" == ประเภท) {url.replace (ใหม่ regexp ("(?:^|/? | &) wd = ([^&]*) (?: & | $)"), ฟังก์ชั่น (a, b, c) {ถ้า (" A.Length - 1); } ถ้า ("sogou" == ประเภท) {url.replace (ใหม่ regexp ("(?:^|/? | &) query = ([^&]*) (?: & | $)"), ฟังก์ชั่น (a, b, c) {if (this._ch! = undefined && A.Length - 1); } อื่นถ้า ("bing" == type) {url.replace (ใหม่ regexp ("(?:^|/? | &) q = ([^&]*) (?: & | $)"), ฟังก์ชั่น (a, b, c) {if (this._ch! A.Length - 1); } } กลับ ""; }, / ******* แทรกค่าลงในอาร์เรย์ ************* / pushValue: ฟังก์ชั่น (คีย์, ค่า) {ถ้า (this._ch! = ไม่ได้กำหนด) {this._ch [key] = value; }}, / *** พารามิเตอร์ที่กำหนดเอง ** / param: ฟังก์ชัน (value) {ถ้า (this._ch! = undefined) {this._ch ["_ ps"] = ค่า; }},/********* ส่งข้อมูลไปยังพื้นหลัง **********/postdata: function () {$ .ajax ({url: "http: // localhost: 28482/ajax/statactions.aspx? t =" + math.random () }, /*** init: function () {ถ้า (this._ch! = undefined) {this._ch = undefined; } this._ch = {}; if (this._reg! = undefined) {this._reg = undefined; } // เริ่มต้น URL การจับคู่นิพจน์ทั่วไป this._reg = new Array (); this._reg [0] = "http://www.google.com.hk (.*)"; this._reg [1] = "http://www.baidu.com (.*)"; this._reg [2] = "http://www.sogou.com (.*)"; this._reg [3] = "http://cn.bing.com (.*)"; // วิเคราะห์พารามิเตอร์ URL var hosturl = window.location.href; if (hosturl! = undefined && hosturl! = "") {ถ้า ((ใหม่ regexp (this._reg [4])). ทดสอบ (Hosturl)) {this._ch ["_ gid"] = this.SearchGid (); } อื่นถ้า ((ใหม่ regexp (this._reg [7])). ทดสอบ (Hosturl)) {} อื่นถ้า ((ใหม่ regexp (this._reg [5])). ทดสอบ (Hosturl)) {this._ch ["_ cid"] = this.SearchCategory (); } อื่นถ้า ((ใหม่ regexp (this._reg [5])). ทดสอบ (Hosturl)) {this._ch ["_ cid"] = this.searchCategory (); } อื่นถ้า ((ใหม่ regexp (this._reg [5])). ทดสอบ (Hosturl)) {this._ch ["_ cid"] = this.searchCategory (); } อื่นถ้า ((ใหม่) regexp (this._reg [6])). ทดสอบ (hosturl)) {this._ch ["_ key"] = this.searchkey (); } this._ch ["_ tu"] = hosturl; } var referrer = document.referrer; if (referrer! = undefined && referrer! = "") {ถ้า ((ใหม่ regexp (this._reg [0])). ทดสอบ (referrer)) {this._ch ["_ key"] = this.SearchSite ("Google"); } อื่นถ้า ((ใหม่ regexp (this._reg [1])). ทดสอบ (referrer)) {this._ch ["_ key"] = this.searchsite ("baidu"); } อื่นถ้า ((ใหม่ regexp (this._reg [2])). ทดสอบ (referrer)) {this._ch ["_ key"] = this.searchsite ("sogou"); } อื่นถ้า ((ใหม่ regexp (this._reg [3])). ทดสอบ (referrer)) {this._ch ["_ key"] = this.searchsite ("bing"); } this._ch ["_ su"] = referrer; } // รับข้อมูลที่เกี่ยวข้องกับลูกค้า this._ch ["_ sw"] = this.screenwidth (); this._ch ["_ sh"] = this.screenheight (); this._ch ["_ bw"] = this.browse (); this._ch ["_ cs"] = this.clientos (); this._ch ["_ mid"] = this.clientid ("from_channelid"); this._ch ["_ ctid"] = this.clientid ("clientkey"); }, _ch: undefined, _reg: undefinedข้างต้นเป็นเนื้อหาทั้งหมดของบทความนี้ สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ JavaScript คุณสามารถตรวจสอบ: "คำแนะนำอ้างอิง JavaScript" และ "คู่มือสไตล์รหัส JavaScript" ฉันหวังว่าทุกคนจะสนับสนุน wulin.com มากขึ้น