javascriptÖÐʼþeventÏê½â
½Å±¾ÖеÄʼþÓÐ2ÖÖÄ£ÐÍ
1¡¢ ðÅÝÐÍʼþ£ºÊ¼þÊÇ°´ÕÕ´Ó×îÌض¨µÄÄ¿±êµ½×î²»Ìض¨µÄʼþÄ¿±ê(document)µÄ˳ÐòÒÀ´Î´¥·¢¡£ÕâÊÇÕë¶Ô²»Í¬ÔªËصÄͬһʼþÀàÐÍ
È磺
<html onclick=”handleClick()”>
<head></head>
<body onclick=”handleClick()”>
<div onclick=”handleClick()”>
</body>
</html>
clickʼþµÄ´¥·¢Ë³ÐòΪdiv——>body——>document
΢ÈíµÄIE¾Í²ÉÓõÄÊÇðÅÝʼþÄ£ÐÍ
2¡¢ ²¶»ñÐÍʼþ£ººÍðÅÝʼþÏà·´£¬Ê¼þÊÇ°´ÕÕ´Ó×î²»Ìض¨µÄÄ¿±ê£¨document£©µ½×îÌض¨µÄÄ¿±êµÄ˳ÐòÒÀ´Î´¥·¢¡£ÕâÊÇÕë¶Ô²»Í¬ÔªËصÄͬһʼþÀàÐÍ
ÈçÉÏÃæµÄʾÀý£¬handleClickʼþµÄ´¥·¢Ë³ÐòΪdocument——>body——>div
±ê×¼µÄDOM²ÉÓÃÁ½ÖÖʼþÄ£ÐÍ£¬¼ÈÓⶻñÐÍʼþ£¬ÓÖÓÐðÅÝÐÍʼþ£¬Óû§¿ÉÒÔ¸ù¾ÝÐèÇóÑ¡ÔñÏàÓ¦µÄʼþÄ£ÐÍ
ʼþ´¦Àíº¯ÊýµÄ°ó¶¨\жÔØ£º
1¡¢ Õë¶ÔIE
[object].attachEvent(“name_of_event_handler”,fnhandler);
[object].detachEvent(“name_of_event_handler”,fnhandler);
È磺
var dom=document.getElementById(“div1”);
dom.attachEvent(“onclick”,handlerClick)
×¢Ò⣺һ¶¨ÒªÔÚʼþÀàÐÍÇ°¼Óon
2¡¢ Õë¶Ô¼æÈÝDOMµÄä¯ÀÀÆ÷
[object].addEventListener(“name_of_event”,fnhandler,bCapture);
[object].removeEventListener(“name_of_event”,fnhandler,bCapture);
×¢Ò⣬µÚÈý¸ö²ÎÊýbCapture±êʾѡÔñµÄʼþÄ£ÐÍ£¬Îªtrue£¬Ñ¡Ôñ²¶»ñÐÍʼþÄ£ÐÍ£¬Îªfalse£¬Ñ¡ÔñðÅÝÐÍʼþÄ£ÐÍ
È磺
var dom =document.getElementById(“div1”);
dom.addEventListener(“click”,handleClick);
×èֹʼþµÄ´«µÝ£º
1¡¢ ×èֹʼþµÄĬÈÏÐÐΪ
ʼþµÄĬÈÏÐÐΪÊÇָһЩԪËØ×ÔÉí°ó¶¨µÄʼþ´¦Àíº¯Êý£¬ÏñÊó±êÓÒ¼üʼþ£¬Îı¾¿òµÄÊäÈëʼþµÈ¡£
Èç¹ûÒª×èÖ¹Êó±êµÄÓÒ¼üʼþ£¬¿ÉÒÔ²ÉÓÃ
l IE
window.event.returnValue=false;
l DOM¼æÈݵÄä¯ÀÀÆ÷
oEvent.preventDefault(); //oEventÔÚDOMÖоÍÊÇʼþ¶ÔÏó
Á½Õß¼æÈݵķ½·¨
document.body.oncontextmenu=functi
Ïà¹ØÎĵµ£º
//°ÑÊý¾ÝдÈëÊý¾Ý¿â
function
res(){
//»ñÈ¡ÊäÈëÖµ(mynameºÍmymailÊÇÁ½¸öÎı¾¿òµÄid)
var
uname = document.getElementById("myname"
).value;
var
umail = document.getElementById("mymail"
).value;
......
ÕâÈý¸öÓïÑÔ·Ö±ðÊÇÈý¸ö¹«Ë¾¿ª·¢µÄ£¬SUNµÄJava£¬NetscapeµÄJavaScript£¬MicrosoftµÄJScript
JavaScriptÊÇÓÉNetscape¹«Ë¾¿ª·¢²¢ËæNavigatorµ¼º½ÕßÒ»Æð·¢²¼µÄ¡¢½éÓÚJavaÓëHTMLÖ®¼ä¡¢»ùÓÚ¶ÔÏóʼþÇý¶¯µÄ±à³ÌÓïÑÔ£¬²»ÐèÒªJava±àÒëÆ÷£¬¶øÊÇÖ±½ÓÔËÐÐÔÚWebä¯ÀÀÆ÷ÖУ¬ËüµÄÇ°ÉíÊÇLive Script¡£
JScriptÊÇÒ»ÖÖÀàËÆJavaScriptµÄÓïÑÔ¡ ......
Ïê½âjavascriptÀà¼Ì³Ð»úÖƵÄÔÀí
Ä¿Ç° javascriptµÄʵÏּ̳з½Ê½²¢²»ÊÇͨ¹ý“extend”¹Ø¼ü×ÖÀ´ÊµÏֵģ¬¶øÊÇͨ¹ýconstructor functionºÍprototypeÊôÐÔÀ´ÊµÏּ̳С£Ê×ÏÈÎÒÃÇ´´½¨Ò»¸öanimalÀà
js ´úÂë
var animal = function(){ //Õâ¾ÍÊÇconstructor function ÁË&nbs ......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor
*/
var File = {
name:'',
path:'',
ext:'',
cfiles:[],
attributes:{
  ......
1 JavaScriptÊý×é¼ò½é
JavaScriptÊý×éÊÇÒ»ÖÖ°üº¬ÒѱàÂëµÄÖµµÄ¸´ºÏÊý¾Ý¡£Êý×éÇø±ðÓÚ¹ØÁªÊý×飬¹ØÁªÊý×éÊǽ«ÖµºÍ×Ö·û´®¹ØÁªÔÚÒ»Æ𣬶øÊý×éÊǽ«ÖµºÍ·Ç¸ºÕûÊý¹ØÁªÔÚÒ»Æð¡£
Êý×éÊǶÔÏó(¿ÉÀûÓÃtypeofÔËËã·û)¡£
2   ......