/*** @author hechen*/var gs = {/** Obter largura da tela **/screenwidth: function () {return window.screen.width; }, / *** Obtenha altura da tela ** / ScreenHeight: function () {return window.screen.height; }, / ** Obtenha o navegador *** / Browse: function () {var Browser = {}; var userAgent = Navigator.UserAgent.TolowerCase (); var s; (s = userAgent.match (/msie ([/d. ]+)/))? navegador.ie = s [1]: (s = userAgent.match (/firefox // ([/d.]+)/))? navegador.firefox = s [1]: (s = userAgent.match (/chrome // ([/d.]+)/))? navegador.chrome = s [1]: (s = userAgent.match (/Ópera. ([/d.]+)/))? navegador.opera = s [1]: (s = userAgent.match (/versão // ([/d.]+).*Safari/))? navegador.safari = s [1]: 0; var versão = ""; if (navegador.ie) {versão = 'ie' + navegador.ie; } else {if (navegador.firefox) {versão = 'firefox' + navegador.firefox; } else {if (navegador.chrome) {versão = 'Chrome' + Browser.chrome; } else {if (BrowSer.opera) {versão = 'Opera' + Browser.opera; } else {if (navegador.safari) {versão = 'safari' + navegador.safari; } else {versão = 'navegador desconhecido'; }}}} Versão de retorno; }, / ** Obtenha o sistema operacional *** / 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"); se (ismac) retornar "Mac"; var isUnix = (Navigator.platform == "x11") &&! iswin &&! ismac; if (iSunix) retornar "Unix"; var isllinux = (String (Navigator.platform) .IndexOf ("Linux")> -1); se (islinux) retornar "Linux"; if (iswin) {var iswin2k = suserAgent.indexof ("Windows nt 5.0")> -1 || SUSeragent.IndexOF ("Windows 2000")> -1; se (iswin2k) retornar "Win2000"; var iswinxp = suserAgent.indexOF ("Windows NT 5.1")> -1 || suserAgent.indexOF ("Windows XP")> -1; if (iswinxp) retornar "winxp"; var iswin2003 = suserragent.indexOF ("Windows nt 5.2")> -1 || suserAgent.IndexOF ("Windows NT 5.2")> -1; if (iswin2003) retornar "Win2003"; var iswinvista = suserragent.indexOF ("Windows NT 6.0")> -1 || SUSeragent.IndexOF ("Windows Vista")> -1; if (iswinvista) retornar "winvista"; var iswin7 = suserragent.indexOF ("Windows NT 6.1")> -1 || SUSeragent.IndexOF ("Windows 7")> -1; if (iswin7) retornar "Win7"; } retornar "outro"; }, / **** Obtenha ID do cliente **** / clientId: function (nome) {var cookies = document.cookie.split (";"); var value = ""; for (var i = 0; i <cookies.length; i ++) {var temp = cookies [i] .split ("="); var tempValue = temp [0] .Prace (/(^/s*) | (/s*$)/g, ""); if (tempValue == nome) {value = UNESCAPE (temp [1]); quebrar; }} retornar valor; }, / **** Get ID do produto **** / SearchGid: function () {var url = window.Location.href; var value = ""; if (url! = indefinido && url! = "") {url.replace (/-/d+-/, function (a, b, c) {if (a! } retornar valor; }, / **** Obtenha a palavra -chave Pesquisa do site **** / Pesquisa: function () {var url = window.location.href; var value = ""; if (url! = indefinido && url! = "") {url.replace (/==/14.*/, function (a, b, c) {if (a! } retornar valor; }, / ** Obtenha o número da pesquisa da categoria do produto ** / SearchCategory: function () {var url = window.location.href; var value = ""; if (url! = indefinido && url! = "") {url.replace (/-/d+/, function (a, b, c) {if (a! } retornar valor; }, / **** Pesquisa off-site Google Baidu ***** / pesquisa: function (type) {var referRer = document.ReferRer; if (referent! A.Substring (A.IndexOF ("=") + 1, A.Length - 1); } else if ("Baidu" == tipo) {url.replace (novo regexp ("(?:^|/? | &) wd = ([^&]*) (?: & | $)"), function (a, b, c) {if (this._ch! A.Length - 1); } else if ("sogou" == tipo) {url.replace (novo regexp ("(?:^|/? | &) Query = ([^&]*) (?: & | $)"), function (a, b, c) {if (this._ch! A.Length - 1); } else if ("bing" == tipo) {url.replace (novo regexp ("(?:^|/? | &) q = ([^&]*) (?: & | $)"), function (a, b, c) {if (this._ch! A.Length - 1); } } retornar ""; }, / ******* Insira o valor na matriz ************* / pushValue: function (key, value) {if (this._ch! = Indefinido) {this._ch [key] = value; }}, / *** parâmetros personalizados ** / param: function (value) {if (this._ch! = Indefinido) {this._ch ["_ ps"] = value; }},/********* Envie dados para o plano de fundo **********/PostData: function () {$ .ajax ({url: "http: // localhost: 28482/ajax/stations.aspx? }, /*** init: function () {if (this._ch! = Indefinido) {this._ch = indefinido; } this._ch = {}; if (this._reg! = indefinido) {this._reg = indefinido; } // inicialize a expressão regular correspondente a 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 (.*)"; // Analise os parâmetros da URL var hosturl = window.location.href; if (hosturl! = indefinido && hosturl! = "") {if ((new regexp (this._reg [4])). test (hosturl)) {this._ch ["_ gid"] = this.searchgid (); } else if ((novo regexp (this._reg [7])). test (hosturl)) {} else if ((new regexp (this._reg [5])). test (hosturl)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((novo regexp (this._reg [5])). test (hosturl)) {this._ch ["_ cid"] = this.searchCategory (); } else if ((novo regexp (this._reg [5])). test (hosturl)) {this._ch ["_ cid"] = this.searchCategory (); } else if ((new) regexp (this._reg [6])). test (hosturl)) {this._ch ["_ key"] = this.searchKey (); } this._ch ["_ tu"] = hosturl; } var referRer = document.ReferRer; if (referent! } else if ((novo regexp (this._reg [1])). test (referent)) {this._ch ["_ key"] = this.searchSite ("Baidu"); } else if ((novo regexp (this._reg [2])). test (referent)) {this._ch ["_ key"] = this.searchSite ("sogou"); } else if ((novo regexp (this._reg [3])). test (referent)) {this._ch ["_ key"] = this.searchSite ("bing"); } this._ch ["_ su"] = referenciador; } // Obtenha informações relacionadas ao cliente 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 ("de_channelid"); this._ch ["_ ctid"] = this.clientId ("clientKey"); }, _ch: indefinido, _reg: indefinidoO acima é o conteúdo inteiro deste artigo. Para obter mais informações sobre JavaScript, você pode conferir: "Javascript Reference Tutorial" e "JavaScript Code Style Guide". Eu também espero que todos apoiem mais wulin.com.