찾다
웹 프론트엔드JS 튜토리얼JavaScript 이벤트 프로세서의 이벤트 매개변수 사용 소개_기본 지식

대부분의 브라우저에서 이벤트 핸들러가 트리거되면 Event라는 클래스의 인스턴스가 첫 번째 매개변수로 핸들러에 전달됩니다. 하지만 늘 주류를 이루던 Internet Explorer는 나름대로 동작하며 Event 인스턴스를 event라는 전역 속성에 저장합니다.

코드 복사 코드는 다음과 같습니다.

if (!event) event=window. event;

위 명령문은 이벤트 매개변수가 정의되지 않았거나 null인지 여부를 감지하는 데 사용됩니다. 그렇다면 창의 이벤트 속성을 할당하여 브라우저 차이를 제거합니다.

대상 요소에 대한 참조를 얻으려면 표준 호환 브라우저의 target 속성과 IE의 srcElement 속성을 사용하여 객체 감지를 통해 이러한 불일치를 처리하세요.
코드 복사 코드는 다음과 같습니다.

var target=(event.target) ? event.target : event.srcElement; >
이 문은 event.target의 정의가 존재하는지 확인합니다. 존재하는 경우 해당 값을 지역 변수 target에 할당하고, 그렇지 않으면 event.srcElement를 target에 할당합니다.
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
PHP8.0中的事件处理库:EventPHP8.0中的事件处理库:EventMay 14, 2023 pm 05:40 PM

PHP8.0中的事件处理库:Event随着互联网的不断发展,PHP作为一门流行的后台编程语言,被广泛应用于各种Web应用程序的开发中。在这个过程中,事件驱动机制成为了非常重要的一环。PHP8.0中的事件处理库Event将为我们提供一个更加高效和灵活的事件处理方式。什么是事件处理在Web应用程序的开发中,事件处理是一个非常重要的概念。事件可以是任何一种用户行

Steam Summer Sale - Valve teases 95% off AAA games, confirms discounts for viral games Palworld and Content WarningSteam Summer Sale - Valve teases 95% off AAA games, confirms discounts for viral games Palworld and Content WarningJun 26, 2024 pm 03:40 PM

Steam's Summer Sale has previously played host to some of the best game discounts, and this year seems to be stacking up for another home run by Valve. A trailer (watch below) teasing some of the Steam Summer Sale discounted games was just released i

Python之Pygame的Event事件模块怎么使用Python之Pygame的Event事件模块怎么使用May 18, 2023 am 11:58 AM

Pygame的Event事件模块事件(Event)是Pygame的重要模块之一,它是构建整个游戏程序的核心,比如常用的鼠标点击、键盘敲击、游戏窗口移动、调整窗口大小、触发特定的情节、退出游戏等,这些都可以看做是“事件”。事件类型Pygame定义了一个专门用来处理事件的结构,即事件队列,该结构遵循遵循队列“先到先处理”的基本原则,通过事件队列,我们可以有序的、逐一的处理用户的操作(触发事件)。下述表格列出了Pygame中常用的游戏事件:名称说明QUIT用户按下窗口的关闭按钮ATIVEEVENTPy

Vue 3中的事件处理器和修饰符,优化用户交互体验Vue 3中的事件处理器和修饰符,优化用户交互体验Sep 08, 2023 am 11:00 AM

Vue3中的事件处理器和修饰符,优化用户交互体验引言:在Vue3中,事件处理器和修饰符是用于优化用户界面交互体验的重要特性。事件处理器允许我们对用户操作作出响应,并执行相应的逻辑。而修饰符则提供了额外的控制和定制事件的行为。本文将详细介绍Vue3中的事件处理器和修饰符,并提供一些实用的代码示例。事件处理器:在Vue3中,我们可以通过v-on指令来绑定

在JavaScript中,当浏览器窗口调整大小时,这是哪个事件?在JavaScript中,当浏览器窗口调整大小时,这是哪个事件?Sep 05, 2023 am 11:25 AM

使用window.outerWidth和window.outerHeight事件在JavaScript中获取窗口大小,当浏览器调整大小时。示例您可以尝试运行以下代码来使用事件检查浏览器窗口大小−<!DOCTYPEhtml><html>  <head>   <script>&am

Steam Summer Sale trailer teases 95% off AAA game deals, confirms price cuts for Palworld, Stellaris, Content WarningSteam Summer Sale trailer teases 95% off AAA game deals, confirms price cuts for Palworld, Stellaris, Content WarningJun 26, 2024 am 06:30 AM

Steam's Summer Sale has previously played host to some of the best game discounts, and this year seems to be stacking up for another home run by Valve. A trailer (watch below) teasing some of the Steam Summer Sale discounted games was just released i

Tesla sends out Robotaxi invitations for October 10 autonomous driving demo event in LATesla sends out Robotaxi invitations for October 10 autonomous driving demo event in LASep 27, 2024 am 06:20 AM

It was initially expected that Tesla would unveil its previously leaked Robotaxi back in August of this year, but CEO Elon Musk postponed the event, citing aesthetic changes to the front of the robotaxi and additional time needed for a few last-minut

Tesla Robotaxi reveal to go ahead on October 10 as invitations go out to select shareholdersTesla Robotaxi reveal to go ahead on October 10 as invitations go out to select shareholdersSep 26, 2024 pm 06:06 PM

It was initially expected that Tesla would unveil its previously leaked Robotaxi back in August of this year, but CEO Elon Musk postponed the event, citing aesthetic changes to the front of the robotaxi and additional time needed for a few last-minut

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는