Vbscript-events-html-ref
提供:Dev Guides
HTMLイベントリファレンス
ユーザーがWebサイトにアクセスすると、テキスト、画像、リンクをクリックしたり、オブジェクトにカーソルを合わせたりするなどの操作を行います。 これらはJavaScriptがイベントと呼ぶものの例です。
JavaScriptまたはVBScriptでイベントハンドラを記述し、これらのイベントハンドラをイベントタグ属性の値として指定できます。 HTML 4.01仕様では、以下にリストする19個のイベント属性を定義しています。
<body>および<frameset>レベルのイベント:
2つの属性のみがあり、ドキュメントレベルでイベントが発生したときにJavaScriptまたはVBScriptコードをトリガーするために使用できます。
| Attribute | Value | Description |
|---|---|---|
| onload | script | Script runs when a HTML document loads |
| onunload | script | Script runs when a HTML document unloads |
- 注:*ここで、スクリプトとは、VBScriptまたはJavaScriptの関数またはコードを指します。
<form>レベルのイベント:
次の6つの属性があり、フォームレベルでイベントが発生したときにJavaScriptまたはVBScriptコードをトリガーするために使用できます。
| 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 |
その他のイベント:
他に次の7つのイベントがあります。これらのイベントは、マウスがHTMLタグと接触すると生成されます。 これらのイベントは、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 |