Html-events-ref
提供:Dev Guides
HTML-イベント参照
ユーザーがウェブサイトにアクセスすると、テキストや画像をクリックしたり、リンクを指定したり、物の上にカーソルを置いたりするなどの操作を行います。 これらはJavaScriptがイベントと呼ぶものの例です。
Javascriptまたはvbscriptでイベントハンドラを記述し、これらのイベントハンドラをイベントタグ属性の値として指定できます。 HTML 4.01仕様では、以下にリストされている19のイベント属性を定義しています-
<body>および<frameset>レベルのイベント
ドキュメントレベルでイベントが発生したときにjavascriptまたはvbscriptコードをトリガーするために使用できる属性は2つだけです。
Attribute | Value | Description |
---|---|---|
onload | script | Script runs when a HTML document loads |
onunload | script | Script runs when a HTML document unloads |
注-ここでのスクリプトは、VBScriptまたはJavaScriptの関数またはコードの一部を指します。
<form>レベルのイベント
フォームレベルでイベントが発生したときにjavascriptまたはvbscriptコードをトリガーするために使用できる次の6つの属性があります。
Attribute | Value | Description |
---|---|---|
onchange | script | Script runs when the element changes |
onsubmit | script | Script runs when the form is submitted |
onreset | script | Script runs when the form is reset |
onselect | script | Script runs when the element is selected |
onblur | script | Script runs when the element loses focus |
onfocus | script | Script runs when the element gets focus |
キーボードイベント
キーボードによって生成される次の3つのイベントがあります。 これらのイベントは、base、bdo、br、frame、frameset、head、html、iframe、meta、param、script、style、およびtitle要素では無効です。
Attribute | Value | Description |
---|---|---|
onkeydown | script | Script runs when key is pressed |
onkeypress | script | Script runs when key is pressed and released |
onkeyup | script | Script runs when key is released |
その他のイベント
マウスがHTMLタグと接触すると、マウスによって生成される他の7つのイベントがあります。 これらのイベントは、base、bdo、br、frame、frameset、head、html、iframe、meta、param、script、style、title要素では無効です。
Attribute | Value | Description |
---|---|---|
onclick | script | Script runs when a mouse click |
ondblclick | script | Script runs when a mouse double-click |
onmousedown | script | Script runs when mouse button is pressed |
onmousemove | script | Script runs when mouse pointer moves |
onmouseout | script | Script runs when mouse pointer moves out of an element |
onmouseover | script | Script runs when mouse pointer moves over an element |
onmouseup | script | Script runs when mouse button is released |