Js gets browser information and page information, and js gets browser pages
1. js gets browser information, including determining whether the browser is mobile or not, browser information, and android version
2. js obtains the url, domain, and title of the page.
Function browserInfo () {var browser = {versions: function () {var u = window. navigator. userAgent; // android var num; if (u. indexOf ('think')>-1) {// IEreturn "IE";} else if (u. indexOf ('presto ')>-1) {// operareturn "Opera";} else if (u. indexOf ('gecko ')>-1 & u. indexOf ('html ') =-1) {// firefoxreturn "Firefox";} else if (u. indexOf ('applewebkit '& u. indexOf ('safari ')>-1)>-1) {// Apple, Google kernel if (u. IndexOf ('chrome ')>-1) {// chromereturn "Chrome";} else if (u. indexOf ('opr') {// webkit Operareturn "Opera_webkit"} else {// Safarireturn "Safari" ;}} else if (u. indexOf ('mobile')>-1) {// if (!! U. match (/\ (I [^;] +; (U ;)? CPU. + Mac OS X/) {// iosif (u. indexOf ('iphone ')>-1) {// iphonereturn "iPhone"} else if (u. indexOf ('ipod ')>-1) {// ipodreturn "iPod"} else if (u. indexOf ('ipad ')>-1) {// ipadreturn "iPad"} else if (u. indexOf ('android')>-1 | u. indexOf ('linux ')>-1) {// androidnum = u. substr (u. indexOf ('android') + 8, 3); return {"type": "Android", "version": num };} else if (u. indexOf ('bb10')>-1) {// return "BB10";} else if (u. indexOf ('iemobile ') {// windows phonereturn "Windows Phone" }}}// browser version var browserVsersion = browser. versions (); // the current page path var url = window. location. href; // the current page domain name var host = window. location. host; // the current page domain name var host2 = document. domain; alert (host2); // the current page title var title = document. title; // source URL urlvar referer; if (document. referrer. length> 0) {referer = document. referrer;} try {if (referer. length = 0 & opener. location. href. length> 0) {referer = opener. location. href ;}} catch (e) {referer = window. location. href;} // current page source urlreferer = referer. replace ('HTTP ://','');}
My personal blog: http://blog.caicongyang.com;
My personal website: http://www.caicongyang.com;
My CSDN blog address: http://blog.csdn.net/caicongyang;