Home Web Front-end JS Tutorial Summary of event object acquisition methods tested under Google browser_javascript skills

Summary of event object acquisition methods tested under Google browser_javascript skills

May 16, 2016 pm 05:17 PM
Get method

Introduction:

The Event object represents the state of the event, such as the element in which the event occurred, the state of the keyboard keys, the position of the mouse, and the state of the mouse button. Events are often used in conjunction with functions, which are not executed until the event occurs!
Getting method of Event object:

Method 1:

For example:

Copy code The code is as follows:

function demo1(e){

var e = e || window.event;

// This method can obtain the event without passing parameter e in IE and Google, but in Firefox, the event parameter

// must be passed in the event method to obtain the event object.

}



Method 2: A universal and convenient method (the convenience of this method is that there is no need to pass parameters)

For example:
Copy code The code is as follows:

function demo2(){

var e = arguments.callee.caller.arguments[0] || window.event;

/ /arguments.callee refers to the current function body

//arguments.callee.caller is the superior function of the current function

//So when onclick="demo2()" is executed, arguments .callee is demo2(), arguments.callee.caller is function onclick,
//The first function of onclick is event, which is arguments.callee.caller.arguments[0].

}



Detailed test summary:

One: The same universal method is to pass the parameter event (the actual parameter must be written as event and other names will not work).

Two: window.event is suitable for IE and Google browsers and Firefox does not support it.

Three: arguments.callee.caller.arguments[0] is only supported by Firefox and Google. IE does not support this acquisition method.

From the above test results, it can be seen that Google Chrome supports the above various acquisition methods and is the most compatible browser.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

A must-read for Java developers: How to obtain administrative district boundary data for administrative division query on Amap A must-read for Java developers: How to obtain administrative district boundary data for administrative division query on Amap Jul 31, 2023 pm 09:05 PM

A must-read for Java developers: How to obtain administrative district boundary data for Administrative Division query on Amap. In the development of geographic information systems (GIS), obtaining administrative division data is a common requirement. When using Amap as a geographical information data source, we can obtain the boundary data of specific administrative regions through the administrative division query interface of Amap. This article will introduce to Java developers how to use the administrative division query interface of Amap to obtain administrative district boundary data. Before we start, we need to apply for an AutoNavi developer account and obtain

How to get HTTP status code in JavaScript the easy way How to get HTTP status code in JavaScript the easy way Jan 05, 2024 pm 01:37 PM

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

Ways to obtain qualifications for the Ming Tide Sonata Test Ways to obtain qualifications for the Ming Tide Sonata Test Jan 23, 2024 pm 10:42 PM

Want to be the first to experience the highly anticipated new game "Song of the Waves"? As a loyal Double Pamish player, you must not miss this opportunity to apply for test qualifications. Next, let me tell you how to apply for the test qualification of Mingchao Sonata. How to obtain qualifications for the Sonata Test: You need to complete the Sonata Test Recruitment Questionnaire and submit it successfully. After the recruitment deadline, some drifters will be selected and given test qualifications. 1. Recruitment time Start time: 11:00 on January 18, 2024 End time: 18:00 on February 7, 2024 2. Test information Test platform: PC, Android, iOS Test type: Limited billing deletion test test Time: The official start time and end time will be notified separately, please pay attention to the official follow-up announcement. 3. Obtaining qualifications 1. First of all, I

Introduction to how to obtain the Fantasy Tower Scavenging Snail and its location Introduction to how to obtain the Fantasy Tower Scavenging Snail and its location Mar 29, 2024 am 08:16 AM

Scavenging snails are a material that belongs to meat in the Fantasy Tower game. Finding the materials is relatively simple, but many friends don’t know the specific location of scavenging snails. The editor briefly summarized it for those who are interested. Friends can join the editor to take a look at how to obtain the Fantasy Tower Scavenging Snail and introduce its location. --How to get the Fantasy Tower Scavenger Snail. Introduction to the location of the Fantasy Tower Scavenger Snail. There is a teleportation point on the top side of Navia. There are many scavenger snails nearby, as shown in the picture below. The number that refreshes in a small ravine or by the river is very good. of.

How to obtain Hulu through Huluxia APP How to obtain Hulu through Huluxia APP Mar 19, 2024 pm 08:10 PM

How to get gourds in Huluxia APP? Calabash Man is a popular mobile game community platform software. Players can download games on the platform, use game assistants, and discuss game information and strategies. Calabash is a currency of the platform. Here is how to obtain Calabash. It helps everyone. Participate in various activities in the community, use the community function of the platform to enter relevant game sections, browse various activity information, and complete the corresponding requirements to obtain gourds. Taking up a position in a game section, such as a moderator or administrator, allows you to provide services to players in return for Hulu. Posting popular posts in the community section can get extra Hulu rewards, and posts that are enhanced will have more Hulu rewards.

How to get win11 preview internal beta version How to get win11 preview internal beta version Dec 29, 2023 pm 07:59 PM

After the win11 system was leaked, it has now provided you with a preview internal beta version. However, there are still many users who don’t know how to update. So here is how to get the win11 preview internal beta version. If you don’t know how to get it, Come and learn. How to get the win11 preview internal beta version: 1. First go to the registry editor and open the path: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsSelfHost\UI\Selection. 2. Right-click in the blank space on the right and select New String Value. A total of 5 new string values ​​need to be created and named: UIBranch key value and modified to Dev. Content

Sharing how to obtain the Rootless Water of the Condor Sharing how to obtain the Rootless Water of the Condor Mar 30, 2024 pm 08:36 PM

How to get the Rootless Water of the Condor? Rootless Water is an important item in the game. Players need to find it when completing related tasks. Many players do not know the specific location. Below, the editor will bring you a guide to obtain the Rootless Water of the Condor Shooting. Friends in need can take a look. 1. Go north from Dr. Tea’s location to the carriage and horse station and enter. 2. Jump to the city wall from the left. 3. After reaching the city wall, go all the way west and go up to the roof. 4. When looking south on the roof, you need to go to the opposite roof. 5. Go to the right after reaching the eaves. 6. You can get [Rootless Water] in the red box.

Sharing how to obtain the Goddess Planet Battle Spirit Sharing how to obtain the Goddess Planet Battle Spirit Feb 01, 2024 pm 01:24 PM

Goddess Planet is an idle adventure game that combines the gameplay of a goddess team. In the game, fighting spirits are an important element to improve the character's strength, and many players hope to obtain more fighting spirits. Let’s take a look at the ways to obtain fighting spirits in the Goddess Planet. 1. Challenge dungeon: By completing various dungeon challenges, players have the opportunity to obtain battle spirit rewards. The higher the difficulty of the dungeon, the more generous the war spirit rewards you will receive. 2. Lottery activities: The game will hold lottery events from time to time. Players can use in-game lottery tickets to participate in the lottery and have a chance to obtain rare fighting spirits. 3 Sharing of methods to obtain battle souls in Goddess Planet 1. Complete the main mission: The main mission in the goddess planet mobile game is an important way to obtain battle souls. By completing missions, players can earn various rewards, including battles

See all articles