


Methods for javascript to determine and obtain trusted sites in the registry_javascript skills
本文实例讲述了javascript判断并获取注册表中可信任站点的方法。分享给大家供大家参考。具体分析如下:
判断可信任站点,首先要在注册表中找到可信任站点在注册表中的位置,如下:
(1)域名作为可信任站点在注册表中的位置:
HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\
(2)IP作为可信任站点在注册表中的位置:
HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges
具体测试代码如下:
index.jsp:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>获取并判断可信任站点(域名和IP)</title> <style type="text/css"> .mainContent{ margin: 0 auto; margin-top: 100px; margin-left: 100px; } </style> <script type="text/javascript" src="js/testRegister.js"></script> </head> <body> <div class="mainContent"> <input type="button" value="是否是可信站点" id="testRegister" /> </div> </body> </html>
js代码:
/* * 判断可信任站点(可信任站点可以为IP地址也可以为域名) */ window.onload = function(){ var btnObj = document.getElementById("testRegister"); btnObj.onclick = function(){ if(navigator.userAgent.indexOf("MSIE") == -1){ alert("只支持IE浏览器!"); return; } var hostname = window.location.hostname; var WshShell = new ActiveXObject("WScript.Shell"); //IP的正则表达式 var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/; //根据域名判断是否存在可信站点 if(hostname != "localhost" && !reg.test(hostname)){ var domainSFlag = false,domainEFlag = false,domainSEFlag = false,domainSSEFlag = true; var hostnamePrefix = "",hostnameSuffix = ""; var indexOf = hostname.indexOf("."); if(indexOf != -1){ hostnamePrefix = hostname.substring(0, indexOf); hostnameSuffix = hostname.substring(indexOf+1, hostname.length); try{ WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + hostname + "\\http"); }catch(e){ domainEFlag = true; } if(domainEFlag){ try{ WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + hostnameSuffix + "\\" + hostnamePrefix + "\\http"); }catch(e){ domainSFlag = true; } } //判断其合法性 if(domainEFlag && domainSFlag){ try{ WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + hostnameSuffix + "\\" + hostnamePrefix + "\\*"); var tipInfo = "<div>您加入的可信站点不是合法的可信站点,请以<span style='color:red;'>http://</span>开头!</div>"; alert(tipInfo); return; }catch(e){} } }else{ try{ WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + hostname + "\\http"); }catch(e){ domainSEFlag = true; } //判断其合法性 if(domainSEFlag){ try{ WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + hostname + "\\*"); var tipInfo = "<div>您加入的可信站点不是合法的可信站点,请以<span style='color:red;'>http://</span>开头!</div>"; alert(tipInfo); return; }catch(e){} } } if((domainSFlag && domainEFlag) || domainSEFlag){ var tipInfo = "域名为" + hostname + "的可信任站点不存在!"; alert(tipInfo); alert(tipInfo); return; } }else{ //获取可信任站点IP,数字2000没法解释,主要涉及到注册表的问题 var str = []; for(var i = 1;i < 2000;i++){ try{ str[i] = WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + i + "\\:Range"); }catch(e){ } } var count = true; for(var i = 1;i < str.length;i++){ if(str[i] == undefined){ continue; }else{ if(str[i] == hostname){ count = false; break; } } } if(count){ var tipInfo = "IP为" + hostname+"可信任站点不存在!"; alert(tipInfo); return } } alert("存在可信任站点!"); } }
希望本文所述对大家的javascript程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In the process of using the Windows 10 operating system, many users find that it takes a long time to start up their computers, which affects the user experience. In order to optimize the boot speed, some people have suggested that the purpose can be achieved by modifying the system registry. In response to this demand, this article will provide an in-depth analysis of how to effectively improve computer startup speed by properly adjusting Windows 10 registry settings. Let’s take a look below. Operation method 1. Use the "win+R" shortcut key to start running, enter "regedit", and click "OK" to open. 2. After entering the Registry Editor, click "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurren" in the left column

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

In the Windows 11 operating system, User Account Control (UAC) serves as a security mechanism that can effectively prevent unauthorized system changes and prompt potential risks. For those who want to adjust the UAC behavior of standard user accounts through deeper settings, this article will explain in detail how to use the Registry Editor tool to make corresponding settings changes in Windows 11 systems. Operation method 1. Right-click "Start" in the taskbar in the lower right corner and select "Run" in the option list. 2. Enter "regedit" in the pop-up run window and press Enter to open it. 3. Then click "Yes" in the prompt window given. 4. After entering the Registry Editor, click "HKEY_" in the left column

Many users have discovered the problem of "the registry file is lost or damaged and therefore cannot be loaded" when using their computers. They don't know how to solve it and have never modified the registry. It is not very troublesome to fix it. It only requires a string of codes. Let’s take a look at the detailed repair methods. The registry file is missing or damaged and therefore cannot be loaded. Repair method 1. Enter "Command Prompt" in the lower left corner of the computer and run it as an administrator. 2. Paste the following code into the command prompt and press the Enter key after entering it. regadd "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsSelfHostApplicability"/v"BranchNam

Although the general operations of domestic mobile phones are very similar, there are still some differences in some details. For example, different mobile phone models and manufacturers may have different dual-SIM installation methods. Erzhenwo 12Pro, a new mobile phone, also supports dual-SIM dual standby, but how should dual-SIM be installed on this phone? How to install dual SIM on Realme 12Pro? Remember to turn off your phone before installation. Step 1: Find the SIM card tray: Find the SIM card tray of the phone. Usually, in the Realme 12 Pro, the SIM card tray is located on the side or top of the phone. Step 2: Insert the first SIM card. Use a dedicated SIM card pin or a small object to insert it into the slot in the SIM card tray. Then, carefully insert the first SIM card.

Question: How to determine whether the date is the previous day in Go language? In daily development, we often encounter situations where we need to determine whether the date is the previous day. In the Go language, we can implement this function through time calculation. The following will be combined with specific code examples to demonstrate how to determine whether the date is the previous day in Go language. First, we need to import the time package in the Go language. The code is as follows: import("time") Then, we define a function IsYest

jQuery is a JavaScript library widely used in web development. It provides many simple and convenient methods to operate web page elements and handle events. In actual development, we often encounter situations where we need to determine whether a variable is empty. This article will introduce several common methods of using jQuery to determine whether a variable is empty, and attach specific code examples. Method 1: Use the if statement to determine varstr="";if(str){co

jQuery Tips: How to Quickly Obtain Screen Height In web development, you often encounter situations where you need to obtain the screen height, such as implementing responsive layout, dynamically calculating element size, etc. Using jQuery, you can easily achieve the function of obtaining the screen height. Next, we will introduce some implementation methods of using jQuery to quickly obtain the screen height, and attach specific code examples. Method 1: Use jQuery's height() method to obtain the screen height. By using jQuery's height
