


Detailed explanation of JS onkeypress compatibility writing method_javascript skills
It is required to enter the password and press Enter to trigger the background event. It seems to be a very simple requirement, but it encounters many problems.
The HTML content mainly includes a password input text box and a button to trigger background events.
1. After the TextBox text box gets focus, just press Enter and the page will refresh.
After careful study of the code, it turns out that when there is only one text box control on the page, the page will be refreshed when pressing Enter.
Solution: Add a hidden TextBox control to the page.
The specific principle is unknown!
2. Use Jquery to implement the method:
$(document).ready(function(){ $("#tbPassword").focus(); $('#bPassword').keydown(function(e){ if(e.keyCode == 13){ $("#ctl00_ContentBody_btnAccept_linkButton")[0].click(); } }); });
3. Due to various reasons, the Jquery implementation method cannot be used, so we have to use JS instead. Its compatibility is the most troublesome issue.
document.getElementByIdx_x_x("tbPassword").onkeypress = function(event){ var keynum; if(window.event) // IE { keynum = window.event.keyCode; } else if(event.which) // Netscape/Firefox/Opera { keynum = event.which; } if (keynum == 13) document.getElementByIdx_x_x('ctl00_ContentBody_btnAccept_linkButton').click(); }
Description:
Read keyboard keys under IE:
keynum = event.keyCode; // 字母d,keynum=100 keychar = String.fromCharCode(keynum); // 将keynum转换成字符d
Read keyboard keys in FireFox:
keynum = event.which; // 字母d,keynum=100 keychar = String.fromCharCode(keynum); // 将keynum转换成字符d
For example, in IE, there is only the keyCode attribute, while in FireFox, there are which and charCode attributes, and in Opera, there are keyCode and which attributes, etc.
Therefore, this compatibility issue has been solved in Jquery.
The above is the entire content of this article, I hope it will be helpful to everyone’s study.

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



Nowadays, many mobile phones claim to support Bluetooth 5.3 version, so what is the difference between Bluetooth 5.3 and 5.2? In fact, they are essentially subsequent updated versions of Bluetooth 5, and there is not much difference in most performance and functions. The difference between Bluetooth 5.3 and 5.2: 1. Data rate 1 and 5.3 can support higher data rates up to 2Mbps. 2. While 5.2 can only reach a maximum of 1Mbps, it means that 5.3 can transmit data faster and more stably. 2. Encryption control enhancement 2. Bluetooth 5.3 improves encryption key length control options, improves security, and can better connect to access control and other devices. 3. At the same time, because the administrator control is simpler, the connection can be more convenient and faster, which is not possible in 5.2.

The performance of i77700 is completely sufficient to run win11, but users find that their i77700 cannot be upgraded to win11. This is mainly due to restrictions imposed by Microsoft, so they can install it as long as they skip this restriction. i77700 cannot be upgraded to win11: 1. Because Microsoft limits the CPU version. 2. Only the eighth generation and above versions of Intel can directly upgrade to win11. 3. As the 7th generation, i77700 cannot meet the upgrade needs of win11. 4. However, i77700 is completely capable of using win11 smoothly in terms of performance. 5. So you can use the win11 direct installation system of this site. 6. After the download is complete, right-click the file and "load" it. 7. Double-click to run the "One-click

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

The Go language has very good compatibility on Linux systems. It can run seamlessly on various Linux distributions and supports processors of different architectures. This article will introduce the compatibility of Go language on Linux systems and demonstrate its powerful applicability through specific code examples. 1. Install the Go language environment. Installing the Go language environment on a Linux system is very simple. You only need to download the corresponding Go binary package and set the relevant environment variables. Following are the steps to install Go language on Ubuntu system:

With the continuous development of modern technology, wireless Bluetooth headsets have become an indispensable part of people's daily lives. The emergence of wireless headphones frees our hands, allowing us to enjoy music, calls and other entertainment activities more freely. However, when we fly, we are often asked to put our phones in airplane mode. So the question is, can I use Bluetooth headphones in airplane mode? In this article, we will explore this question. First, let’s understand what airplane mode does and means. Airplane mode is a special mode for mobile phones

1. Right-click the program and find that the [Compatibility] tab is not found in the properties window that opens. 2. On the Win10 desktop, right-click the Start button in the lower left corner of the desktop and select the [Run] menu item in the pop-up menu. 3. The Win10 run window will open, enter gpedit.msc in the window, and then click the OK button. 4. The Local Group Policy Editor window will open. In the window, click the [Computer Configuration/Administrative Templates/Windows Components] menu item. 5. In the opened Windows component menu, find the [Application Compatibility] menu item, and then find the [Remove Program Compatibility Property Page] setting item in the right window. 6. Right-click the setting item, and in the pop-up menu

The software in the win10 system has been perfectly optimized, but for the latest win11 users, everyone must be curious about whether this system can be supported, so the following is a detailed introduction to the win11 software that does not support win10. Come and find out together. Does win11 support win10 software: 1. Win10 system software and even Win7 system applications are well compatible. 2. According to feedback from experts who use the Win11 system, there are currently no application incompatibility issues. 3. So you can upgrade boldly with confidence, but ordinary users are advised to wait until the official version of Win11 is released before upgrading. 4. Win11 not only has good compatibility, but also has Windo

The driver of a hardware device is one of the most important programs for us to use this device normally, but sometimes we may encounter that the driver we download and install is incompatible. In fact, the system can automatically find a compatible driver to download and install. Let’s take a look at it together. Just give it a try. How to make win10 driver compatible? 1. First find this computer on the desktop, right-click and select to open "Properties" 2. Then find and open "Device Manager" on the left 3. Find the device you want to download and install in the device manager, right-click and select "Update driver" 4. Then select "Automatically search for updated driver software" 5. Finally, wait for a while and the following window will pop up, which means the driver installation is complete.
