⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtml_events.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>DHTML Events</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

<style>
<!--
div.Section1
	{page:Section1;}
-->
</style>
</head>

<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

<h1>DHTML Event Handlers</h1>
<a href="dhtml_dom.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dhtml_css.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<p class="intro">HTML events can trigger actions in the browser, like starting a 
JavaScript when a user clicks on an element.</p>
<h2 style="color:red" onclick="this.innerHTML='Ooops!'">Don't Click On This Text</h2>
<hr />

<h2>Examples</h2>

<p><a target="_blank" href="tryit.asp@filename=trydhtml_examples_image">onclick</a><br />Turn on the light! How 
to change an image when the user clicks it.</p>

<p><a target="_blank" href="tryit.asp@filename=trydhtml_event_onmousedown">onmousedown &amp; onmouseup</a><br />This time the light 
is on only when the user holds down the mouse button.</p>

<p><a target="_blank" href="tryit.asp@filename=trydhtml_event_onload">onload</a><br />
Displays an alert box when the page has finished loading.</p>

<hr />
<h2>Event handlers</h2>
<p>An event handler allows you to execute code when an event 
occurs.</p>
<p>Events are generated by the browser when the user clicks an element, when the page loads, when a form is submitted, 
etc.</p>
<h3>Example</h3>
<p>A header changes when the user clicks it:</p>

<table class="ex" cellspacing="0" border="1" width="100%">
  <tbody>
    <tr>
      <td>
        <pre>&lt;h1 onclick=&quot;this.innerHTML='Ooops!'&quot;&gt;Click on this text&lt;/h1&gt;</pre>
      </td>
    </tr>
  </tbody>
</table>

<p><a target="_blank" href="tryit.asp@filename=trydhtml_event_onclick2">Try it yourself</a></p>
<p>You can also add a script in the head section of
the page and then call the function from the event handler:</p>

<table class="ex" cellspacing="0" border="1" width="100%">
  <tbody>
    <tr>
      <td>
        <pre>&lt;html&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function changetext(id)
{
id.innerHTML=&quot;Ooops!&quot;;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1 onclick=&quot;changetext(this)&quot;&gt;Click on this text&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
      </td>
    </tr>
  </tbody>
</table>
<br />

<hr />

<h2>HTML 4.0 Event Handlers</h2>

<table class="ex" cellspacing="0" border="1" width="100%">
  <tr>
    <th width="30%" align="left">Event</th>
    <th width="70%" align="left">Occurs when...</th>
  </tr>
  <tr>
    <td>onabort</td>
    <td>a user aborts page loading</td>
  </tr>
  <tr>
    <td>onblur</td>
    <td>a user leaves an object</td>
  </tr>
  <tr>
    <td>onchange</td>
    <td>a user changes the value of an object</td>
  </tr>
  <tr>
    <td>onclick</td>
    <td>a user clicks on an object</td>
  </tr>
  <tr>
    <td>ondblclick</td>
    <td>a user double-clicks on an object</td>
  </tr>
  <tr>
    <td>onfocus</td>
    <td>a user makes an object active</td>
  </tr>
  <tr>
    <td>onkeydown</td>
    <td>a keyboard key is on its way down</td>
  </tr>
  <tr>
    <td>onkeypress</td>
    <td>a keyboard key is pressed</td>
  </tr>
  <tr>
    <td>onkeyup</td>
    <td>a keyboard key is released</td>
  </tr>
  <tr>
    <td>onload</td>
    <td>a page is finished loading</td>
  </tr>
  <tr>
    <td>onmousedown</td>
    <td>a user presses a mouse-button</td>
  </tr>
  <tr>
    <td>onmousemove</td>
    <td>a cursor moves on an object</td>
  </tr>
  <tr>
    <td>onmouseover</td>
    <td>a cursor moves over an object</td>
  </tr>
  <tr>
    <td>onmouseout</td>
    <td>a cursor moves off an object</td>
  </tr>
  <tr>
    <td>onmouseup</td>
    <td>a user releases a mouse-button</td>
  </tr>
  <tr>
    <td>onreset</td>
    <td>a user resets a form</td>
  </tr>
  <tr>
    <td>onselect</td>
    <td>a user selects content on a page</td>
  </tr>
  <tr>
    <td>onsubmit</td>
    <td>a user submits a form</td>
  </tr>
  <tr>
    <td>onunload</td>
    <td>a user closes a page</td>
  </tr>
</table>
<br />
<hr />
<h2>More About HTML Events</h2>
<p>For a full overview please refer to the complete
<a href="../htmldom/dom_obj_event.asp">DOM Event Object Reference</a> in our HTML 
DOM tutorial.</p>
<hr />

<a href="dhtml_dom.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dhtml_css.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -