/ *** @author Hechen * / var gs = {/ ** Get Screen Width ** / Screenwidth: function () {return window.screen.width; }, / *** Get Screen Height ** / ScreenHeight: function () {return window.screen.height; }, / ** Get Browser *** / Browse: function () {var Browser = {}; var userAgent = Navigator.UserAgent.tolowerCase (); var s; (s = userAgent.match (/ msie ([/d. Browser.ie = S [1]: (s = userAgent.match (/ firefox // ([/ d.] +) /))? Browser.firefox = s [1]: (s = userAgent.match (/ chrome // ([/ d.] +) /))? Browser.Chrome = S [1]: (s = userAgent.match (/ opera. ([/ d.] +) /))? Browser.Opera = S [1]: (s = userAgent.match (/ version // ([/ d.] +). * safari /))? Browser.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 = 'Browser inconnu'; }}}} version de retour; }, / ** Obtenez le système d'exploitation *** / clientoS: function () {var suserager = Navigator.UserAgent; var iswin = (navigator.platform == "win32") || (navigator.platform == "Windows"); var ismac = (navigator.platform == "mac68k") || (Navigator.platform == "macppc") || (Navigator.platform == "Macintosh") || (navigator.platform == "Macintel"); si (isMac) renvoie "mac"; var isunix = (navigator.platform == "x11") &&! iswin &&! Ismac; if (isunix) renvoie "Unix"; var isLinux = (String (Navigator.Platform) .Indexof ("Linux")> -1); if (isLinux) renvoie "Linux"; if (iswin) {var iswin2k = suseragent.indexof ("Windows nt 5.0")> -1 || suserager.indexof ("Windows 2000")> -1; si (ISWIN2K) renvoie "win2000"; var iswinxp = suserager.indexof ("Windows NT 5.1")> -1 || suseragent.indexof ("Windows XP")> -1; if (iswinxp) renvoie "winxp"; var iswin2003 = suserager.indexof ("Windows NT 5.2")> -1 || susserragent.indexof ("Windows NT 5.2")> -1; if (iswin2003) renvoie "win2003"; var iswinvista = suserager.indexof ("Windows NT 6.0")> -1 || suseragent.indexof ("Windows Vista")> -1; si (iswinvista) renvoie "winvista"; var iswin7 = suseragent.indexof ("Windows NT 6.1")> -1 || suserager.indexof ("Windows 7")> -1; if (iswin7) renvoie "win7"; } return "autre"; }, / **** Get Client Id **** / ClientId: Function (Name) {var cookies = document.cookie.split (";"); var valeur = ""; for (var i = 0; i <cookies.length; i ++) {var temp = cookies [i] .split ("="); var tempvalue = temp [0] .replace (/ (^ / s *) | (/ s * $) / g, ""); if (tempValue == name) {value = unescape (temp [1]); casser; }} valeur de retour; }, / **** Get Product ID **** / Searchgid: function () {var url = window.location.href; var valeur = ""; if (url! = Undefined && url! = "") {url.replace (/ - / d + - /, fonction (a, b, c) {if (a! = undefined && a! = "" && a.Length> 2) {value = a.subString (1, a.LengthD - 1);}}); } RETOUR-valeur; }, / **** Obtenez le mot-clé de recherche de site **** / searchKey: function () {var url = window.location.href; var valeur = ""; if (url! = Undefined && url! = "") {url.replace (/ ·= dos .*/, fonction (a, b, c) {if (a! = undefined && a! = "" && a.Length> 1) {value = a.subString (1);}}); } RETOUR-valeur; }, / ** Obtenir le numéro de recherche de catégorie de produit ** / searchCategory: function () {var url = window.location.href; var valeur = ""; if (url! = Undefined && url! = "") {url.replace (/ - / d + /, fonction (a, b, c) {if (a! = undefined && a! = "" && a.Length> 1) {value = a.subString (1);}}); } RETOUR-valeur; }, / **** Recherche hors site Google baidu ***** / searchSite: function (type) {var référent = document.Referrer; if (référent! = UNDEFINED && référent! = "") {if ("google" == type) {url.replace (new regexp ("(?: ^ | /? | &) q = ([^ &] *) (?: & | $)"), fonction (a, b, c) {if (this._ch! = undefined && a! = undfined " A.SubString (A.Indexof ("=") + 1, A.Length - 1); } else if ("baidu" == type) {url.replace (new regexp ("(?: ^ | /? | &) wd = ([^ &] *) (?: & | $)"), function (a, b, c) {if (this._ch! = Undefined && a! = Undefined &&.LengthD> 0) {a = a.substring (a.indexof (") + 1) {a = a a.substring (a.indexof (") + 1, 0) {a = a.sUsbstring (a.indexof (") + 1) {a = a.SUSBSTRING (a.indexof () A.Length - 1); } else if ("sogou" == type) {url.replace (new regexp ("(?: ^ | /? | &) Query = ([^ &] *) (?: & | $)"), function (a, b, c) {if (this._ch! = Undefined && a! = Undefined &&.LengthDeg A.Length - 1); } else if ("bing" == type) {url.replace (new regexp ("(?: ^ | /? | &) q = ([^ &] *) (?: & | $)"), fonction (a, b, c) {if (this._ch! = Undefined && a! = undefinexof (") A.Length - 1); } } retour ""; }, / ******* Insérez la valeur dans le tableau *********** / pushValue: fonction (clé, valeur) {if (this._ch! = Undefined) {this._ch [key] = value; }}, / *** Paramètres personnalisés ** / param: fonction (valeur) {if (this._ch! = Undefined) {this._ch ["_ ps"] = valeur; }}, / ********* Soumettre des données à l'arrière-plan ********** / PostData: function () {$ .ajax ({url: "http: // localhost: 28482 / ajax / statacts.aspx? T =" + math.random (), type: "post", data: this._ch, Success: function (data) {}}); }, / *** init: function () {if (this._ch! = Undefined) {this._ch = undefined; } this._ch = {}; if (this._reg! = Undefined) {this._reg = undefined; } // Initialisez l'URL de correspondance d'expression régulière 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 (. *)"; // Analyser les paramètres d'URL var hosturl = window.location.href; if (hostul! = undefined && hostul! = "") {if ((new regexp (this._reg [4])). test (hostul)) {this._ch ["_ gid"] = this.searchgid (); } else if ((new regexp (this._reg [7])). test (hostul)) {} else if ((new regexp (this._reg [5])). test (hostul)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((new regexp (this._reg [5])). test (hostul)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((new regexp (this._reg [5])). test (hostul)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((new) regexp (this._reg [6])). test (hostul)) {this._ch ["_ key"] = this.searchKey (); } this._ch ["_ tu"] = hostul; } var référent = document.Referrer; if (référent! = Undefined && référent! = "") {if ((new regexp (this._reg [0])). test (référent)) {this._ch ["_ key"] = this.searchSite ("google"); } else if ((new regexp (this._reg [1])). Test (Ref-Referrer)) {this._ch ["_ key"] = this.searchSite ("baidu"); } else if ((new regexp (this._reg [2])). Test (Ref-ReferRer)) {this._ch ["_ key"] = this.searchSite ("sogou"); } else if ((new regexp (this._reg [3])). Test (Ref-Referrer)) {this._ch ["_ key"] = this.searchSite ("bing"); } this._ch ["_ su"] = référent; } // obtenir des informations liées au client 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: non défini, _reg: indéfiniCe qui précède est l'intégralité du contenu de cet article. Pour plus d'informations sur JavaScript, vous pouvez consulter: "JavaScript Reference Tutorial" et "JavaScript Code Style Guide". J'espère également que tout le monde soutiendra davantage Wulin.com.