common event in js

/ / 1: onblur event occurs when the object loses focus
function upperCase ()
(
var x = document.getElementById ( "fname"). value
document.getElementById ( "fname"). value = x.toUpperCase ()
)
</ script>

Enter your name:
<input type="text" />

/ / 2: onabort events will be interrupted when the image is loaded happen.
<script type="text/javascript">
function abortImage ()
(
alert ( 'Error: Loading of the image was aborted')
)
</ script>
</ head>

<body>
<img src="image_w3default.gif" onabort="abortImage()" />
</ body>

/ / 3: onchange event in the domain of content changes happen
<script type="text/javascript">
function upperCase (x)
(
var y = document.getElementById (x). value
document.getElementById (x). value = y.toUpperCase ()
)
</ script>
</ head>
<body>
Enter your name:
<input type="text" onchange="upperCase(this.id)" />

/ / 4: onclick when the user clicks on an object when the event handler calls.
/ / 5: onclick when an object when the user double-click event handler calls.

/ / 6: onerror event will be in the document or image loading process is triggered when an error occurs.
<img src="image.gif" />

/ / 7: onfocus incident happened when the object was the focus.
<script type="text/javascript">
function setStyle (x)
(
document.getElementById (x). style.background = "yellow"
)
</ script>
</ head>
<body>
First name: <input type = "text"
onfocus = "setStyle (this.id)" />
<br />
Last name: <input type = "text"
onfocus = "setStyle (this.id)" />
</ body>

/ / 8: onkeydown event in the user press a keyboard button when
<script type="text/javascript">
function noNumbers (e)
(
var keynum
var keychar
var numcheck
if (window.event) / / IE
(
keynum = e.keyCode
)
else if (e.which) / / Netscape / Firefox / Opera
(
keynum = e.which
)
keychar = String.fromCharCode (keynum)
numcheck = / \ d /
return! numcheck.test (keychar)
)
</ script>
<form>
<input type="text" onkeydown="return noNumbers(event)" />
</ form>

/ / 9: onkeyup event will be at the keyboard when keys are released
<script type="text/javascript">
function upperCase (x)
(
var y = document.getElementById (x). value
document.getElementById (x). value = y.toUpperCase ()
)
</ script>
</ head>
<body>
Enter your name: <input type="text" onkeyup="upperCase(this.id)" />
</ body>

/ / 10: onload event of the page or image is loaded immediately after the completion of (onload when the page finished loading in the status bar shows a section of text)
<script type="text/javascript">
function load ()
(
window.status = "Page is loaded"
)
</ script>
</ head>
<body onload="load()">
</ body>

/ / 11: onmousedown event will be the mouse button is pressed happen (the dialog box will show you click on the element tag name)
<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>

/ / 12: onmousemove event occurs when the mouse pointer movement
<img src="/i/eg_mouse2.jpg" alt="mouse" onmousemove="alert(' Your mouse just after pictures !')" />

/ / 13: onmouseout event is the mouse pointer out of the designated object happen
<img src="/i/example_mouse2.jpg" alt="mouse" onmousemove="alert(' Your mouse have just left the picture !')" />

/ / 14: onmouseover time the mouse pointer will move to the designated object happen when
<img src="/i/eg_mouse2.jpg" alt="mouse""alert(' Your mouse on the picture !')" />

/ / 15: onmouseup event will be release the mouse button when
<img src="/i/eg_mouse2.jpg" alt="mouse" onmouseup="alert(' You click on the picture !')" />

/ / 16: onresize incident would have been in the window or frame size adjust happen (when the user tries to adjust the size of the window will display a dialog box)
<body onresize="alert('You have changed the size of the window')">
</ body>

/ / 17: onselect event text in the text box is selected when
<form>
Select text: <input type = "text" value = "Hello world!"
onselect = "alert ( 'You have selected some of the text.')" />
Select text: <textarea cols = "20" rows = "5"
onselect = "alert ( 'You have selected some of the text .')">
Hello world! </ Textarea>
</ form>

/ / 18: onunload event in the user exit when the page (turn off when the page will display a dialog box)
<body onunload="alert('The onunload event was triggered')">
</ body>

分类:AJAX 时间:2009-03-03 人气:601
分享到:
blog comments powered by Disqus

相关文章

  • FLASH must solve the double click to use, and IE6 popup FLASH Player Press OK to continue loading the ... 2010-11-02

    No need to use IE, click the activation method can be embedded in Flash, ie swfobject.js <div></div> <script type='text/javascript'> var so = new SWFObject('flash/top.swf','mpl','750','278','9'); so.addParam('quality','high'); so.addPara

  • JavaScript can achieve double-click to edit text 2009-10-22

    <! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=&quo

  • Text box text field textarea picture double-click the preview text realization 2010-05-05

    js code: <script type="text/javascript"> function ShowPreview(objid){ var obj = document.getElementById(objid); var r = document.selection.createRange(); var s = "TMP"; var rt = r.text; var rv = rt+s; r.text = rt+s; var i = obj.v

  • Double-click to edit 2009-07-24

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <% String path = request.getContextPath(); String basePath = request.getScheme(

  • Double-click to start image 2010-05-04

    main.jsp <c:set var="showpage" value="${requestScope.showpage}"/> <c:if test="${empty showpage}"> <c:set var="showpage" value="welcome.jsp"/> </c:if> <table border="0"

  • Double-click the Cancel radio 2010-11-25

    <! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=&quo

  • Solve the click and double-click the event of conflict 2011-05-25

    The first is: If a DOM object in the same bind-click (click) and double (dblclick) event, when the DOM object in the double-click event occurs on the first click (click) will trigger a click (click) event, the second click (consecutive) will also tri

  • Double-click event does not trigger realization jquery click event 2010-05-05

    Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title&g

  • jquery achieve double-click event does not trigger click event 2010-05-05

    Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title&g

  • javascript onerror event 2010-06-10

    Source: http://www.w3school.com.cn/js/js_onerror.asp As long as the page script error occurs, it will produce onerror event. If you need to use onerror event, you must create a function to handle errors. You can put this function is called onerror ev

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.268 (s). 12 q(s)