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 人气:610
分享到:
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

  • HTML教程:INPUT type=text元素 | input type=text对象 2014-09-30

    INPUT type=text元素 | input type=text 创建一个单行的文本输入控件. 成员表 下面的表格列出了 input type=text 对象引出的成员.请单击左侧的标签来选择你想要查看的成员类型. 标签属性/属性 标签属性 属性 描述 ACCESSKEY accessKey 设置或获取对象的快捷键. ATOMICSELECTION 指定 元素 及其内容是否可以一不可见单位统一选择. AUTOCOMPLETE autocomplete 设置或获取对象的自动完成状态. BEG

  • 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

  • JavaScript and PHP to implement a form submit button way more than the source code 2010-10-29

    JavaScript and PHP to implement a form submit button way more than the source code Today, when doing the background to deal with a form, the form with two submit buttons, to achieve a different submit button when clicked, respectively, for two differ

  • firefox下input type="file"的size是多大 2014-12-20

    firefox对type="file" 的input的width定义目前是不支持的,但是FF支持size属性,可以给size设置一个值,来控制上传框的大小 但是这个size值怎么设置,size="10"是多宽,默认值又是多少,不能光凭感觉去设置. 用脚本来查看下: <script type="text/javascript"> $(function() { var fileArray = []; var i = 0; while (i

  • js 实现 input type="file" 文件上传示例代码 2015-04-18

    在开发中,文件上传必不可少但是它长得又丑.浏览的字样不能换,一般会让其隐藏点其他的标签(图片等)来时实现选择文件上传功能 在开发中,文件上传必不可少,<input type="file" /> 是常用的上传标签,但是它长得又丑.浏览的字样不能换,我们一般会用让,<input type="file" />隐藏,点其他的标签(图片等)来时实现选择文件上传功能. 看代码: <!DOCTYPE html> <html xmlns=&

  • 禁用input type为checkbox或radio时的click默认事件 2014-12-03

    在input中,如果type为checkbox或radio时,浏览器会将该input渲染成为系统的单选或多选组件,如果这时,我们在这个input上绑定click事件,那就要小心谨慎使用e.preventDefault()这个方法(jQuery中整合了这个方法使得它能够兼容去掉浏览器中的默认事件).之所以要说谨慎使用,就是,如果你在这个事件的响应程序中判断该checkbox是否选中时,得到的结果和真正的选中状态会有所不同.下面先从一个简单的示例说明这个现象.(为了简单起见,我使用了jquery,他

  • nginx gzip duplicate MIME type "text / html" 2010-09-14

    Instruction [# Gzip gzip] [# Gzip_buffers gzip_buffers] [# Gzip_comp_level gzip_comp_level] [# Gzip_min_length gzip_min_length] [# Gzip_http_version gzip_http_version] [# Gzip_proxied gzip_proxied] [# Gzip_types gzip_types] After the upgrade to the l

  • Dynamically change the input type tag attributes (such as the password to text) 2010-12-25

    <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <script> function removeSubmitFocus () { document.all ('pass'). outerHTML = "<input type = text name ='" + document

  • 如何用正则取input type="text"中的value 2014-02-04

    1.如何通过正则取input type="text"中的value呢? 2.如何过滤掉input type="checkbox"的标签? 这样只能达到正则取input type="text"中的value可是不能过滤掉input type="checkbox"的标签! alert [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] alert [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 解决: aler

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

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

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