onmousedown ʼþ
¶¨ÒåºÍÓ÷¨
onmousedown ʼþ»áÔÚÊó±ê°´¼ü±»°´ÏÂʱ·¢Éú¡£
Óï·¨
onmousedown="SomeJavaScriptCode"
²ÎÊý | ÃèÊö |
---|---|
SomeJavaScriptCode | ±ØÐè¡£¹æ¶¨¸Ãʼþ·¢ÉúʱִÐÐµÄ JavaScript¡£ |
Ö§³Ö¸ÃʼþµÄ HTML ±êÇ©£º
<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>
Ö§³Ö¸ÃʼþµÄ JavaScript ¶ÔÏó£º
button, document, link
ʵÀý
ÔÚ±¾ÀýÖУ¬µ±Äúµã»÷ÏÂÃæµÄͼƬʱ»áµ¯³öÒ»¸ö¶Ô»°¿ò£º
<img src="/i/example_mouse2.jpg"
onmousedown="alert('You clicked the picture!')"
/>
Êä³ö£º£¨Çëµã»÷ͼƬ£©

ʵÀý 2
ÔÚ±¾ÀýÖУ¬¶Ô»°¿ò½«ÏÔʾ³öÄúËùµã»÷µÄÔªËØµÄ±êÇ©Ãû£º
<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.")
}
</script>
</head>
<body onmousedown="whichElement(event)"
>
<h2>This is a header</h2>
<p>This is a paragraph</p>
<img border="0" src="ball16.gif" alt="Ball">
</body>
</html>
TIY
- onmousedown
- ÈçºÎʹÓà onmousedown ÔÚͼÏñ±»µã»÷ʱÏÔʾһ¸ö¶Ô»°¿ò¡£
- onmousedown 2
- ÈçºÎʹÓà onmousedown À´ÏÔʾÄúËùµã»÷µÄÔªËØµÄ±êÇ©Ãû¡£