qqjianyue代码工

砌java代码
posts - 62, comments - 9, trackbacks - 0, articles - 10
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Javascript 基本事件模型

Posted on 2009-05-22 15:51 Qzi 阅读(371) 评论(0)  编辑  收藏
标准的基本事件:

Event Attribute

Event Description

Allowed Elements Under
Standard (X)HTML

onblur

Occurs when an element loses focus, meaning that the user has activated another element, typically either by clicking the other element
or tabbing to it.

<a>, <area>, <button>, <input>, <label>, <select>, <textarea>
Also <applet>, <area>, <div>, <embed>, <hr>, <img>, <marquee>, <object>, <span>, <table>, <td>, <tr>
In IE4+ and N4 also <body>
In N4 also <frameset>, <ilayer>, <layer>

onchange

Signals that the form field has lost user focus and its value has been modified during this
last access.

<input>, <select>, <textarea>

onclick

Indicates that the element has been clicked.

Most display elements*
In IE4+ also <applet>, <font>

ondblclick

Indicates that the element has been
double-clicked.

Most display elements*
In IE4+ also <applet>, <font>

onfocus

Indicates that the element has received focus; in other words, it has been selected by the user for manipulation or data entry.

<a>, <area>, <button>, <input>, <label>, <select>, <textarea>
In IE4+ also <applet>, <div>, <embed>, <hr>, <img>, <marquee>, <object>, <span>, <table>, <td>, <tr>
In IE4+ and N4 also <body>
In N4 also <frameset>, <ilayer>, <layer>

onkeydown

Indicates that a key is being pressed down with focus on the element.

Most display elements*
In IE4+ also <applet>, <font>

onkeypress

Indicates that a key has been pressed and released with focus on the element.

Most display elements*
In IE4+ also <applet>, <font>

onkeyup

Indicates that a key is being released with focus on the element.

Most display elements*
In IE4+ also <applet>, <font>

onload

Indicates that the object (typically a window or frame set) has finished loading into the browser.

<body>, <frameset>
In IE4+ also <applet>, <embed>, <link>, <script>, <style>
In N4 also <ilayer>, <layer>
In IE4+ and N4 also <img>

onmousedown

Indicates the press of a mouse button with focus on the element.

Most display elements*
In IE4+ also <applet>, <font>

onmousemove

Indicates that the mouse has moved while over the element.

Most display elements*
In IE4+ also <applet>, <font>

onmouseout

Indicates that the mouse has moved away from
an element (i.e., is no longer above the element).

Most display elements*
In IE4+ also <applet>, <font>
In N4 also <ilayer>, <layer>

onmouseover

Indicates that the mouse has moved over
the element.

Most display elements*
In IE4+ also <applet>, <font>
In N4 also <ilayer>, <layer>

onmouseup

Indicates the release of a mouse button with focus on the element.

Most display elements*
In IE4+ also <applet>, <font>

onreset

Indicates that the form is being reset, possibly by the press of a reset button.

<form>

onselect

Indicates the selection of text by the user, typically by highlighting it with the mouse.

<input>, <textarea>

onsubmit

Indicates that the form is about to be submitted, generally the result of activating a Submit button.

<form>

onunload

Indicates that the browser is navigating away from the current document, and unloading it from the window or frame.

<body>, <frameset>


非标准的事件:
Event Attribute Event Description Permitted Elements Compatibility

onabort

Triggered by the user aborting the image load via the Stop button or similar mechanism.

<img>

Netscape 3, 4–4.7
Internet Explorer 4+

onactivate

Fires when the element becomes the active element, that is, the element that will have focus when its parent frame or window has focus.

Most display elements

Internet Explorer 5.5+

onafterprint

Fires after user prints
document or previews
document for printing.

<body>, <frameset>

Internet Explorer 5+

onafterupdate

Fires after the transfer of
data from the element to
a data provider.

<applet>, <body>, <button>, <caption>, <div>, <embed>,
<img>, <input>, <marquee>, <object>, <select>, <table>,
<td>, <textarea>, <tr>

Internet Explorer 4+

onbeforeactivate

Fires just before the element becomes the active element (see onactivate)

Most display elements

Internet Explorer 5.5+

onbeforecopy

Fires just before selected content is copied and placed
in the user's system clipboard.

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <caption>, <center>, <cite>, <code>, <custom>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> – <h6>, <i>, <img>, <label>, <legend>, <li>, <listing>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>, <s>, <samp>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <td>, <textarea>, <th>, <tr>, <tt>, <u>, <ul>

Internet Explorer 5+

onbeforecut

Fires just before selected content is cut from the document and added to
the system clipboard.

<a>, <address>, <applet>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <center>, <cite>, <code>, <custom>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <embed>, <fieldset>, <font>, <form>, <h1> – <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <listing>, <map>, <marquee>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>,
<rt>, <ruby>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <xmp>

Internet Explorer 5+

onbeforedeactivate

Fires just before the active element changes from the current element to some other.

Most display elements

Internet Explorer 5.5+

onbeforeeditfocus

When using design mode or the contenteditable feature, fires when a contained element receives focus for editing.

Most elements

Form fields in Internet Explorer 5, all elements in Internet Explorer 5.5+

onbeforepaste

Fires before selected content is pasted into a document.

<a>, <address>, <applet>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <center>, <cite>, <code>, <custom>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <embed>, <fieldset>, <font>, <form>, <h1> – <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <listing>, <map>, <marquee>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>,
<rt>, <ruby>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <xmp>

Internet Explorer 5+

onbeforeprint

Fires before user prints document or previews
document for printing.

<body>, <frameset>

Internet Explorer 5+

onbeforeunload

Fires just prior to a document being unloaded from a window.

<body>, <frameset>

Internet Explorer 4+

onbeforeupdate

Triggered before the transfer
of data from the element to the data provider. Might be triggered explicitly, by a loss of focus
or by a page unload forcing a data update.

<applet>, <body>, <button>, <caption>, <div>, <embed>,
<hr>, <img>, <input>, <object>, <select>, <table>, <td>, <textarea>, <tr>

Internet Explorer 4+

onbounce

Triggered when the bouncing contents of a marquee touch one side or another.

<marquee>

Internet Explorer 4+

oncellchange

Fires when data changes at the data provider.

<applet>, <bdo>, <object>

Internet Explorer 5+

oncontextmenu

Fires when the user clicks the right mouse button to bring up the context-dependent menu.

Most elements

Internet Explorer 5+, Mozilla-based browsers

oncontrolselect

When using design mode or
the contenteditable feature, fires when the user selects
the object.

Most elements

Internet Explorer 5.5+

oncopy

Fires on target when selected content is copied from the document to the clipboard.

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <caption>, <center>, <cite>, <code>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> – <h6>, <hr>, <i>, <img>, <legend>, <li>, <listing>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>, <s>, <samp>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <td>, <th>, <tr>, <tt>, <u>, <ul>

Internet Explorer 5+

oncut

Fires when selected content
is cut from the document and added to system clipboard.

<a>, <address>, <applet>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <center>, <cite>, <code>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <embed>, <fieldset>, <font>, <form>, <h1> – <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <listing>, <map>, <marquee>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>,
<rt>, <ruby>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <xmp>

Internet Explorer 5+

ondataavailable

Fires when data arrives from data sources that transmit information asynchronously.

<applet>, <object>

Internet Explorer 4+

ondatasetchanged

Triggered when the initial
data is made available
from the data source or
when the data changes.

<applet>, <object>

Internet Explorer 4+

ondatasetcomplete

Indicates that all the data is available from the data source.

<applet>, <object>

Internet Explorer 4+

ondrag

Fires continuously on an object being dragged

Most elements

Internet Explorer 5+

ondragdrop

Triggered when the user drags an object onto the browser window to attempt to load it.

<body>, <frameset> (window)

Netscape 4–4.7

ondragend

Fires on object being dragged when the user releases the mouse button at the end of
a drag operation.

Most elements

Internet Explorer 5+

ondragenter

Fires on a valid drop target when the user drags an object over it.

Most elements

Internet Explorer 5+

ondragleave

Fires on a valid drop target when the user drags an object away from it.

Most elements

Internet Explorer 5+

ondragover

Fires continuously on a valid drop target while the user drags an object over it.

Most elements

Internet Explorer 5+

ondragstart

Fires when the user begins to drag a highlighted selection.

<a>, <acronym>, <address>, <applet>, <area>, <b>, <big>, <blockquote>, <body> (document), <button>, <caption>, <center>, <cite>, <code>, <dd>, <del>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <font>, <form>, <frameset> (document), <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <hr>, <i>, <img>, <input> <bd>, <label>, <li>, <listing>, <map>, <marquee>, <menu>, <object>, <ol>, <option>, <p>, <plaintext>, <pre>, <q>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <xmp>

Internet Explorer 4+

ondrop

Fires on a valid drop target when the user drags an object onto it and releases the
mouse button.

Most elements

Internet Explorer 5+

onerror

Fires when the loading of a document or the execution of
a script causes an error. Used to trap runtime errors.

<body>, <frameset> (window), <img> (as well as <link>, <object>, <script>, <style> in Internet Explorer 4)

Netscape 3, 4–4.7
Internet Explorer 4+

onerrorupdate

Fires if a data transfer has been canceled by the onbeforeupdate event handler.

<a>, <applet>, <object>, <select>, <textarea>

Internet Explorer 4+

onfilterchange

Fires when a page CSS filter changes state or finishes.

Most elements

Internet Explorer 4+

onfinish

Triggered when a looping marquee finishes.

<marquee>

Internet Explorer 4+

onfocusin

Fires just before the element receives focus.

Most elements

Internet Explorer 6+

onfocusout

Fires just before the element loses focus.

Most elements

Internet Explorer 6+

onhelp

Triggered when the user presses the F1 key or similar help button in the user agent.

Most elements

Internet Explorer 4+

onlayoutcomplete

Fires when the layout area has been prepared for printing or print preview.

<base>, <basefont>, <bgsound>, <br>, <col>, <dd>, <div>, <dl>, <dt>, <font>, <head>, <hr>, <html>, <layoutrect>, <li>, <meta>, <ol>, <option>, <p>, <title>, <ul>

Internet Explorer 6

onlosecapture

Fires when the element loses mouse capture (IE enables an element to receive events for all mouse events, even if they don't occur at that element).

Most elements

Internet Explorer 5+

onmouseenter

Fires when the user moves the mouse over the element (different from onmouseover only in its bubbling behavior).

Most elements

Internet Explorer 5.5+

onmouseleave

Fires when the user moves the mouse away from the element (different from onmouseout only in its bubbling behavior).

Most elements

Internet Explorer 5.5+

onmousewheel

Fires when the mouse wheel is rotated by the user.

Most elements

Internet Explorer 6

onmove

Triggered when the user moves the window.

<body>, <frameset>

Netscape 4–4.7

onmove

Fires when the object moves
on screen.

Most display elements.

Internet Explorer 5.5+

onmoveend

Fires just after an object has finished moving on screen.

Most display elements.

Internet Explorer 5.5+

onmovestart

Fires just before an object is about to move on screen.

Most display elements.

Internet Explorer 5.5+

onpaste

Fires when content is pasted into the document.

<a>, <address>, <applet>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <center>, <cite>, <code>, <dd>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <embed>, <fieldset>, <font>, <form>, <h1> – <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <listing>, <map>, <marquee>, <menu>, <nobr>, <ol>, <p>, <plaintext>, <pre>,
<rt>, <ruby>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <xmp>

Internet Explorer 5+

onpropertychange

Fires whenever a property of the element (or one of its contained objects, for example, its style object) changes.

Most elements.

Internet Explorer 5+

onreadystatechange

Similar to onload. Fires whenever the ready state for
an object has changed.

<applet>, <body>, <embed>, <frame>, <frameset>, <iframe>, <img>, <link>, <object>, <script>, <style>

Internet Explorer 4+

onresize

Triggered whenever an object is resized. Can only be bound to the window under Netscape via the <body> tag.

<applet>, <body>, <button>, <caption>, <div>, <embed>, <frameset>, <hr>, <img>, <marquee>, <object>, <select>,
<table>, <td>, <textarea>, <tr>

Netscape 4, 4.5 (supports <body> only); Internet Explorer 4+

onresizeend

When using design mode or the contenteditable feature, fires after the user finishing resizing an object.

Most elements

Internet Explorer 5.5+

onresizestart

When using design mode or the contenteditable feature, fires when the user begins resizing an object.

Most elements.

Internet Explorer 5.5+

onrowenter

Indicates that a bound data row has changed and new data values are available.

<applet>, <body>, <button>, <caption>, <div>, <embed>,
<hr>, <img>, <marquee>, <object>, <select>, <table>, <td>, <textarea>, <tr>

Internet Explorer 4+

onrowexit

Fires just prior to a bound data source control changing the current row.

<applet>, <body>, <button>, <caption>, <div>, <embed>,
<hr>, <img>, <marquee>, <object>, <select>, <table>, <td>, <textarea>, <tr>

Internet Explorer 4+

onrowsdelete

Fires just before rows are deleted from a recordset.

<applet>, <object>, <xml>

Internet Explorer 5+

onrowsinserted

Fires just after rows are added to a recordset.

<applet>, <object>, <xml>

Internet Explorer 5+

onscroll

Fires when a scrolling element is repositioned.

<body>, <div>, <fieldset>, <img>, <marquee>, <span>, <textarea>

Internet Explorer 4+

onselectionchange

Fires when the selection state of the document changes.

Document object

Internet Explorer 5.5+

onselectstart

Fires when the user begins
to select information by highlighting.

Nearly all elements.

Internet Explorer 4+

onstart

Fires when a looped marquee begins or starts over.

<marquee>

Internet Explorer 4+

onstop

Fires when the user clicks
the browser's Stop button,
or leaves the Web page

Document object

Internet Explorer 5+


可以直接调用的元素方法:

Event Method

Elements

click()

<input type="button">, <input type="checkbox">, <input type="reset">, <input type="submit">, <input type="radio">, <a> (not in DOM, though commonly supported)

Blur()

<select>, <input>, <textarea>, <a>

focus()

<select>, <input>, <textarea>, <a>

select()

<input type="text">, <input type="password">, <input type="file">, <textarea>

submit()

<form>

reset()

<form>


Netscape4的event属性列表

Property

Description

>data

Array of strings containing the URLs of objects that were dragged and dropped.

>modifiers

Bitmask indicating which modifier keys were held down during the event. The bitmask is a bitwise combination of the constants: ALT_MASK, CONTROL_MASK, META_MASK, and SHIFT_MASK, which are static (class) properties of the Event object. For example, if the alt and ctrl keys were depressed, modifiers will have value (Event.ALT_MASK & Event.CONTROL_MASK).

>pageX

Numeric value indicating the horizontal coordinate where the event occurred.

>pageY

Numeric value indicating the vertical coordinate where the event occurred.

>screenX

Numeric value indicating the horizontal coordinate where the event occurred relative to the whole screen.

>screenY

Numeric value indicating the vertical coordinate where the event occurred relative to the whole screen.

>target

Reference to the object at which the event occurred.

>type

String containing the event type (for example, "click").

>which

For mouse events, numeric value indicating which mouse button was used
(1 is left, 2 middle, 3 right); for keyboard events, the numeric (Unicode) value of the key pressed.


只有注册用户登录后才能发表评论。


网站导航: