這次帶給大家如何使用JS取得電腦配置,如何使用JS取得電腦配置的注意事項有哪些,以下就是實戰案例,一起來看一下。
nbsp;html> <meta> <title></title> <style> h1 { text-align: center; color: #000046; } .i { display: inline-block; vertical-align: middle; width: 30px; height: 30px; margin: 5px 20px; background: url(http://yi.sunlands.com/ent-portal-war/images/tc_icon.png) no-repeat; } .a { background-position: 0 0; } .b { background-position: 0 -40px; } .c { background-position: 0 -80px; } .d { background-position: 0 -120px; } .e { background-position: 0 -160px; } b { color: #007ac3; padding-right: 10px; } i { color: green; font-weight: bold; } .box { width: 460px; height: 360px; margin: auto; padding: 20px; border: 2px solid darkgray; font-size: 18px; border-radius: 10px; border-left-width: 10px; border-right-width: 10px; } </style> <h1 id="电脑配置检测">电脑配置检测</h1> <hr> <p> </p><p> <i></i> <b>您的操作系统是: </b> <i></i> </p> <p> <i></i> <b>您的网络链接状态是: </b> <i></i> </p> <p> <i></i> <b>您当前浏览网速是:</b> <i></i> </p> <p> <i></i> <b>您电脑的分辨率是:</b> <i></i> </p> <p> <i></i> <b>您的浏览器是:</b> <i></i> </p> <p> <i></i> <b>您的flash的版本是:</b> <i></i> </p> <script></script> <script> $(function(){ if(typeof Obj == "undefined") { var Obj = new Object(); } if(typeof Obj.SWFObjectUtil == "undefined") { Obj.SWFObjectUtil = new Object(); } Obj.SWFObject = function(_1, id, w, h, _5, c, _7, _8, _9, _a) { if(!document.getElementById) return; this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if(_1) this.setAttribute("swf", _1); if(id) this.setAttribute("id", id); if(w) this.setAttribute("width", w); if(h) this.setAttribute("height", h); if(_5) this.setAttribute("version", new Obj.PlayerVersion(_5.toString().split("."))); this.installedVer = Obj.SWFObjectUtil.getPlayerVersion(); if(!window.opera && document.all && this.installedVer.major > 7) { Obj.SWFObject.doPrepUnload = true; } if(c) this.addParam("bgcolor", c); var q = _7 ? _7 : "high"; this.addParam("quality", q); this.setAttribute("useExpressInstall", false); this.setAttribute("doExpressInstall", false); var _c = (_8) ? _8 : window.location; this.setAttribute("xiRedirectUrl", _c); this.setAttribute("redirectUrl", ""); if(_9) this.setAttribute("redirectUrl", _9); }; Obj.SWFObject.prototype = { useExpressInstall: function(_d) { this.xiSWFPath = !_d ? "expressinstall.swf" : _d; this.setAttribute("useExpressInstall", true); }, setAttribute: function(_e, _f) { this.attributes[_e] = _f; }, getAttribute: function(_10) { return this.attributes[_10]; }, addParam: function(_11, _12) { this.params[_11] = _12; }, getParams: function() { return this.params; }, addVariable: function(_13, _14) { this.variables[_13] = _14; }, getVariable: function(_15) { return this.variables[_15]; }, getVariables: function() { return this.variables; }, getVariablePairs: function() { var _16 = new Array(); var key; var _18 = this.getVariables(); for(key in _18) { _16[_16.length] = key + "=" + _18[key]; } return _16; }, getSWFHTML: function() { var _19 = ""; if(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { if(this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\""; _19 += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" "; var _1a = this.getParams(); for(var key in _1a) { _19 += [key] + "=\"" + _1a[key] + "\" "; } var _1c = this.getVariablePairs().join("&"); if(_1c.length > 0) { _19 += "flashvars=\"" + _1c + "\""; } _19 += "/>"; } else { if(this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">"; _19 += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />"; var _1d = this.getParams(); for(var key in _1d) { _19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />"; } var _1f = this.getVariablePairs().join("&"); if(_1f.length > 0) { _19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />"; } _19 += ""; } return _19; }, write: function(_20) { if(this.getAttribute("useExpressInstall")) { var _21 = new Obj.PlayerVersion([6, 0, 65]); if(this.installedVer.versionIsValid(_21) && !this.installedVer.versionIsValid(this.getAttribute("version"))) { this.setAttribute("doExpressInstall", true); this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl"))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } if( this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) { var n = (typeof _20 == "string") ? document.getElementById(_20) : _20; n.innerHTML = this.getSWFHTML(); return true; } else { if(this.getAttribute("redirectUrl") != "") { document.location.replace(this.getAttribute("redirectUrl")); } } return false; } }; Obj.PlayerVersion = function(_29) { this.major = _29[0] != null ? parseInt(_29[0]) : 0; this.minor = _29[1] != null ? parseInt(_29[1]) : 0; this.rev = _29[2] != null ? parseInt(_29[2]) : 0; }; Obj.SWFObjectUtil.getPlayerVersion = function() { var _23 = new Obj.PlayerVersion([0, 0, 0]); if(navigator.plugins && navigator.mimeTypes.length) { var x = navigator.plugins["Shockwave Flash"]; if(x && x.description) { _23 = new Obj.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } } else { if(navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) { var axo = 1; var _26 = 3; while(axo) { try { _26++; axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + _26); _23 = new Obj.PlayerVersion([_26, 0, 0]); } catch(e) { axo = null; } } } else { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch(e) { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); _23 = new Obj.PlayerVersion([6, 0, 21]); axo.AllowScriptAccess = "always"; } catch(e) { if(_23.major == 6) { return _23; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if(axo != null) { _23 = new Obj.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } } return _23; }; //获取浏览器flash版本号 function getFlashVersion() { var version = Obj.SWFObjectUtil.getPlayerVersion(); $("#flash_banben").html(version['major'] + "." + version['minor'] + "." + version['rev']); }; //获取操作系统屏幕分辨率 function getScreenSize() { return { width: screen.width, height: screen.height }; } $("#fenbianlv").html(getScreenSize().width + "*" + getScreenSize().height); function getNetline() { $('#netline').text("网络已链接"); window.ononline = function() { $('#netline').text("网络已链接"); }; window.onoffline = function() { $('#netline').text("网络已断开"); }; } //获取浏览器版本 function getExplorerVersion() { var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var result = ""; (s = ua.match(/qqbrowser\/([\d.]+)/)) ? Sys.qqbrowser = s[1]: (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = ua.match(/(trident)\/([\d.]+)/)) ? Sys.ie = '11.0' : (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0; if(Sys.ie) result = "IE " + Sys.ie; else if(Sys.firefox) result = "firefox " + Sys.firefox; else if(Sys.chrome) result = "chrome " + Sys.chrome; else if(Sys.opera) result = "opera " + Sys.opera; else if(Sys.safari) result = "safari" + Sys.safari; else if(Sys.qqbrowser) result = "QQBrowser" + Sys.qqbrowser; else result = "未知"; $("#liulanqi").html(result + "(内核)"); } //获取操作系统版本 function getOsVersion() { var opName = ""; var Name = ""; var ua = window.navigator.userAgent; var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows") || (navigator.platform == "Win64"); var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel"); if(isMac) { opName = "Mac"; Name = "Mac"; } else if(isWin) { var osN = ""; if(ua.indexOf("WOW") != -1 || ua.indexOf("Win64") != -1) { osN = "64"; } else { osN = "32"; } var osV = ua.substr(ua.indexOf("Windows NT ") + 11, 3); switch(osV) { case "5.0": opName = "Windows XP2000"; Name = "Win2000"; break; case "5.1": opName = "Windows XP "; Name = "WinXP"; break; case "5.2": opName = "Windows 2003"; Name = "Win2003"; break; case "6.1": opName = "Windows 7 " + osN + "位"; Name = "Win7"; break; case "6.3": opName = "Windows 8 " + osN + "位"; Name = "Win8"; break; default: Name = "Other"; break; } } else { var isUnix = (navigator.platform == "X11") && !isWin && !isMac; if(isUnix) { opName = "Unix"; Name = "Unix"; } else { var isLinux = (String(navigator.platform).indexOf("Linux") > -1); if(isLinux) { opName = "Linux"; Name = "Linux"; } else { Name = "Other"; } } } $("#xitong").html(opName); } //获取网速 function getNet() { var starttime = new Date(); var size = 0, //文件长度,由脚本使用HEAD自动计算 url = "2017-08-22_233329.jpg?" + new Date().valueOf(); //获取文件的长度: var xhr = $.ajax({ type: 'get', //"head", url: url, success: function(msg) { size = xhr.getResponseHeader('Content-Length'); //开始GET数据: $.get(url, function(data) { var endtime = new Date(); usetime = endtime - starttime; if(usetime == 0) { usetime = 10; } var speed = (size / (1024)) / (usetime / (1000)); var result_text = speed.toFixed(2); $("#wangsu").html(result_text + "KB/S"); }); } }); } getNet(); getOsVersion(); getExplorerVersion(); getFlashVersion(); getNetline(); }()); </script>
我相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!
建議閱讀:
################################################# ####以上是如何使用JS取得電腦配置的詳細內容。更多資訊請關注PHP中文網其他相關文章!

不同JavaScript引擎在解析和執行JavaScript代碼時,效果會有所不同,因為每個引擎的實現原理和優化策略各有差異。 1.詞法分析:將源碼轉換為詞法單元。 2.語法分析:生成抽象語法樹。 3.優化和編譯:通過JIT編譯器生成機器碼。 4.執行:運行機器碼。 V8引擎通過即時編譯和隱藏類優化,SpiderMonkey使用類型推斷系統,導致在相同代碼上的性能表現不同。

JavaScript在現實世界中的應用包括服務器端編程、移動應用開發和物聯網控制:1.通過Node.js實現服務器端編程,適用於高並發請求處理。 2.通過ReactNative進行移動應用開發,支持跨平台部署。 3.通過Johnny-Five庫用於物聯網設備控制,適用於硬件交互。

我使用您的日常技術工具構建了功能性的多租戶SaaS應用程序(一個Edtech應用程序),您可以做同樣的事情。 首先,什麼是多租戶SaaS應用程序? 多租戶SaaS應用程序可讓您從唱歌中為多個客戶提供服務

本文展示了與許可證確保的後端的前端集成,並使用Next.js構建功能性Edtech SaaS應用程序。 前端獲取用戶權限以控制UI的可見性並確保API要求遵守角色庫

JavaScript是現代Web開發的核心語言,因其多樣性和靈活性而廣泛應用。 1)前端開發:通過DOM操作和現代框架(如React、Vue.js、Angular)構建動態網頁和單頁面應用。 2)服務器端開發:Node.js利用非阻塞I/O模型處理高並發和實時應用。 3)移動和桌面應用開發:通過ReactNative和Electron實現跨平台開發,提高開發效率。

JavaScript的最新趨勢包括TypeScript的崛起、現代框架和庫的流行以及WebAssembly的應用。未來前景涵蓋更強大的類型系統、服務器端JavaScript的發展、人工智能和機器學習的擴展以及物聯網和邊緣計算的潛力。

JavaScript是現代Web開發的基石,它的主要功能包括事件驅動編程、動態內容生成和異步編程。 1)事件驅動編程允許網頁根據用戶操作動態變化。 2)動態內容生成使得頁面內容可以根據條件調整。 3)異步編程確保用戶界面不被阻塞。 JavaScript廣泛應用於網頁交互、單頁面應用和服務器端開發,極大地提升了用戶體驗和跨平台開發的靈活性。

Python更适合数据科学和机器学习,JavaScript更适合前端和全栈开发。1.Python以简洁语法和丰富库生态著称,适用于数据分析和Web开发。2.JavaScript是前端开发核心,Node.js支持服务器端编程,适用于全栈开发。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版

Dreamweaver Mac版
視覺化網頁開發工具