JS get browser information and page information

Source: Internet
Author: User

1.js Get Browser Info: Contains information about whether the mobile side, and browser info, Android version

2.js get page URL, domain, title

function Browserinfo () {var browser = {Versions:function () {var u = Window.navigator.useragent;//android version var num;if (U. IndexOf (' Trident ') >-1) {//iereturn "IE";} else if (U.indexof (' Presto ') >-1) {//operareturn "Opera";} else if (u.i Ndexof (' Gecko ') >-1 && u.indexof (' khtml ') = =-1) {//firefoxreturn "Firefox";} else if (U.indexof (' AppleWebKit ' && u.indexof (' Safari ') >-1) >-1) {//Apple, Google kernel if (u.indexof (' Chrome ') >-1) {//chromereturn "Chrome";} E LSE if (U.indexof (' OPR ')) {//webkit Operareturn "Opera_webkit"} else {//safarireturn "Safari";}} else if (U.indexof (' mobile ') >-1) {//Mobile if (!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/) {//iosif (u.indexof (' iphone ') >-1) {//iphonereturn "iphone"} else if (U.indexof (' IPod ') >-1) {//i Podreturn "IPod"} else if (U.indexof (' ipad ') >-1) {//ipadreturn "ipad"}} else if (U.indexof (' Android ') > -1| | u.ind Exof (' Linux ') >-1) {//androidnum = U.substr (U.indexof (' Android ') + 8, 3); return {"Type": "anDroid "," Version ": num};} else if (u.indexof (' BB10 ') >-1) {//BlackBerry BB10 system return "BB10";} else if (U.indexof (' Iemobile ')) {//windows Phonereturn "Win dows Phone "}}}}//browser version var browservsersion = Browser.versions ();//current page path var url = window.location.href;//Current page domain name var host = window.location.host;//Current page domain name Var host2=document.domain; alert (host2);//Current page title var title = document.title;//Source Address 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;





JS get browser information and page information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.