/*** @author hechen*/var gs = {/** Получить ширину экрана **/screenwidth: function () {return window.screen.width; }, / *** Получить высоту экрана ** / screenHeight: function () {return window.screen.height; }, / ** Получить браузер *** / browse: function () {var browser = {}; var userAgent = navigator.useragent.tolowercase (); var s; (s = userAgent.match (/msie ([/д. Затем+)/))? 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 = 'Неизвестный браузер'; }}}} return версии; }, / ** Получить операционную систему *** / 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"); if (iSmac) вернуть "Mac"; var isUnix = (navigator.platform == "x11") &&! Iswin &&! Ismac; if (isunix) вернуть "unix"; var islinux = (string (navigator.platform) .indexof ("linux")> -1); if (islinux) вернуть "linux"; if (iswin) {var iswin2k = suseragent.indexof ("Windows nt 5.0")> -1 || suseragent.indexof ("Windows 2000")> -1; if (iswin2k) возврат "win2000"; var ISWINXP = SUSERAGENT.INDEXOF ("Windows NT 5.1")> -1 || suseragent.indexof ("Windows XP")> -1; if (iswinxp) возврат "winxp"; var ISWIN2003 = suseragent.indexof ("Windows NT 5.2")> -1 || suseragent.indexof ("Windows NT 5.2")> -1; if (iSwin2003) возврат "Win2003"; var iswinvista = suseragent.indexof ("Windows NT 6.0")> -1 || suseragent.indexof ("Windows Vista")> -1; Если (iswinvista) вернет "Уинвиста"; var iswin7 = suseragent.indexof ("Windows NT 6.1")> -1 || suseragent.indexof ("Windows 7")> -1; if (iswin7) возврат "win7"; } вернуть "Другое"; }, / **** Получить идентификатор клиента **** / clientId: function (name) {var cookies = document.cookie.split (";"; "); var value = ""; for (var i = 0; i <cookies.length; i ++) {var temp = cookie [i] .split ("="); var tempvalue = temp [0] .Replace (/(^/s*) | (/s*$)/g, ""); if (tempvalue == name) {value = unescape (temp [1]); перерыв; }} return value; }, / **** Получить идентификатор продукта **** / searchgid: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.replace (/-/d+-/, function (a, b, c) {if (a! = undefined && a! = "" "" } return value; }, / **** Получить ключевое слово поиска сайта **** / searchkey: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.Replace (/*=n.*/, function (a, b, c) {if (a! = undefined && a! = "" " } return value; }, / ** Получить номер поиска категории продукта ** / searchCategory: function () {var url = window.location.href; var value = ""; if (url! = undefined && url! = "") {url.Replace (/-/d+/, function (a, b, c) {if (a! = undefined && a! = "" "" } return value; }, / **** Поиск за пределами площадки Google Baidu ***** / Searchsite: function (type) {var Referrer = document.ReferRer; if (Referrer! = Undefined && Referrer! = "") {if ("Google" == type) {url.Replace (новая regexp ("(?:^|/? | &) q = ([^&]*) (? A.Substring (A.IndExof ("=") + 1, A.Length - 1); } else if ("baidu" == type) {url.replace (new Regexp ("(?:^|/? | &) wd = ([^&]*) (? A.Length - 1); } else if ("sogou" == type) {url.replace (new regexp ("(?:^|/? | &) Query = ([^&]*) (? A.Length - 1); } else if ("bing" == type) {url.replace (new regexp ("(?:^|/? | &) q = ([^&]*) (? A.Length - 1); } } возвращаться ""; }, / ******* Вставьте значение в массив ************* / pushvalue: function (key, value) {if (this._ch! = Undefined) {this._ch [key] = value; }}, / *** Пользовательские параметры ** / param: function (value) {if (this._ch! = Undefined) {this._ch ["_ ps"] = value; }},/********* Отправить данные на фон **********/postdata: function () {$ .ajax ({url: "http: // localhost: 28482/ajax/statactions.aspx? T =" + math.random (), тип: ", data: this._ch, успех: function (data); }, /*** init: function () {if (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! = "") {if ((новая regexp (this._reg [4])). test (hosturl)) {this._ch ["_ gid"] = this.searchgid (); } else if ((новая regexp (this._reg [7])). test (hosturl)) {} else if ((new regexp (this._reg [5])). test (hosturl)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((новая regexp (this._reg [5])). test (hosturl)) {this._ch ["_ cid"] = this.searchcategory (); } else if ((новая 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 (Referrer! = Undefined && Referrer! = "") {if ((новая regexp (this._reg [0])). test (referrer)) {this._ch ["_ key"] = this.searchsite ("google"); } else if ((новая regexp (this._reg [1])). test (referrer)) {this._ch ["_ key"] = this.searchsite ("baidu"); } else if ((новая regexp (this._reg [2])). test (referrer)) {this._ch ["_ key"] = this.searchsite ("sogou"); } else if ((новая regexp (this._reg [3])). test (referrer)) {this._ch ["_ key"] = this.searchsite ("bing"); } this._ch ["_ su"] = Реферат; } // Получить информацию, связанную с клиентом 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: не определен, _reg: не определенВышеуказанное - все содержание этой статьи. Для получения дополнительной информации о JavaScript вы можете проверить: «Справочный учебник JavaScript» и «Руководство по стилю кода JavaScript». Я также надеюсь, что все будут поддерживать Wulin.com больше.