(0) exportieren Drucken
Alle erweitern
EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.
25 von 58 fanden dies hilfreich - Dieses Thema bewerten.

attachEvent method

[attachEvent is no longer supported. Starting with Internet Explorer 11, use addEventListener. For info, see Compatibility changes.]

Binds the specified function to an event, so that the function gets called whenever the event fires on the object.

Syntax

object.attachEvent(event, pDisp)

Parameters

event [in]

Type: String

String that specifies any of the standard DHTML Events.

pDisp [in]

Type: Object

Pointer that specifies the function to call when event fires.

Return value

Type: Boolean

Boolean. Returns one of the following possible values:
Return valueDescription
true

The function was bound successfully to the event.

false

The function was not bound to the event.

 

Standards information

There are no standards that apply here.

Remarks

When event fires on the object, the object's event handler is called before pDisp, the specified function. If you attach multiple functions to the same event on the same object, the functions are called in random order, immediately after the object's event handler is called.

The attachEvent method enables a behavior to handle events that occur on the containing page. This method is not limited, however, to behaviors. You can also define a function on a page that attaches to events fired on the same page.

Behaviors that attach to events using the attachEvent method must explicitly call the detachEvent method to stop receiving notifications from the page when the ondetach event fires.

A behavior that attaches to events on the page using the HTML Component (HTC) PUBLIC:ATTACH element automatically stops receiving notifications when the behavior detaches from the element, and does not need to call the detachEvent method.

Note  To use the attachEvent method with Microsoft Visual Basic Scripting Edition (VBScript), you need to use the GetRef to obtain a function pointer. The function pointer can then be passed to attachEvent.

Examples

The attachEvent method has been deprecated and samples have been removed. Microsoft recommends the use of addEventListener instead.

See also

a
abbr
acronym
address
applet
area
article
aside
b
base
baseFont
bgSound
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
comment
custom
dd
del
dfn
dir
div
dl
document
dt
em
embed
fieldSet
figcaption
figure
font
footer
form
frame
frameSet
head
header
hgroup
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
kbd
label
legend
li
link
listing
map
mark
marquee
menu
namespace
nav
noBR
object
ol
option
p
plainText
pre
q
s
samp
script
section
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
window
xmp
Reference
detachEvent
Conceptual
Introduction to DHTML Behaviors
Using DHTML Behaviors
Using HTML Components to Implement DHTML Behaviors in Script

 

 

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Vielen Dank für Ihr Feedback.
Anzeigen:
© 2014 Microsoft. Alle Rechte vorbehalten.