js获取设备信息的方法汇总

注:本文转自傲雪星枫

1.获取访问者IP及所在地


<html>
 <head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8">
  <title>javascript获取访问者IP及所在地title>
  <script src="http://pv.sohu.com/cityjson?ie=utf-8">script>
 head>

 <body>
  <script type="text/javascript">
    document.write("IP: " + returnCitySN['cip'] + "
地区代码: "
+ returnCitySN['cid'] + "
所在地: "
+ returnCitySN['cname']);
script> body> html>

输出:

IP: 61.140.62.124
地区代码: 440100
所在地: 广东省广州市

2.获取访问者设备信息

"-//W3C//DTD HTML 4.0 Transitional//EN">

 
  "content-type" content="text/html;charset=utf-8">
  javascript获取访问者设备信息
 

 
  
 

输出:

userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:56.0) Gecko/20100101 Firefox/56.0

appName: Netscape

appCodeName: Mozilla

appVersion: 5.0 (Macintosh)

appMinorVersion: undefined

platform: MacIntel cookieEnabled: true onLine: true userLanguage: zh-CN mimeTypes.description: Shockwave Flash mimeTypes.type: application/x-shockwave-flash

你可能感兴趣的:(js)