検索
ホームページウェブフロントエンドjsチュートリアルJavaScriptイベントプロセッサのイベントパラメータの使い方入門_基礎知識

ほとんどのブラウザでは、イベント ハンドラーがトリガーされると、Event という名前のクラスのインスタンスが最初のパラメーターとしてハンドラーに渡されます。ただし、常に主流であった Internet Explorer は独自の方法で動作し、Event インスタンスをイベントと呼ばれるグローバル属性に保存します。

コードをコピー コードは次のとおりです:

if (!event)event=window。 event;

上記のステートメントは、イベント パラメーターが未定義か null かを検出するために使用され、その場合はウィンドウのイベント属性を割り当て、ブラウザーの違いを排除します。

ターゲット要素への参照を取得するには、標準準拠のブラウザでは target 属性を使用し、IE では srcElement 属性を使用してオブジェクト検出を通じてこの不一致を処理します
コードをコピーします コードは次のとおりです:

var target=(event.target) ?event.target :
このステートメントは、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ヘンタイを無料で生成します。

ホットツール

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

DVWA

DVWA

Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。