Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

·ÅÒ»¸öjavascriptÓÒ¼ü²Ëµ¥µÄ´úÂë

×¢²áºÜ³¤Ê±¼äºÅÁË£¬¸Õ¿ªÍ¨²©¿Í£¬ÄóöÒ»¸ö×Ô¼ºÐ´µÄjavascriptÓÒ¼ü²Ëµ¥£¬¼æÈÝIE£¬firefoxä¯ÀÀÆ÷
ÕâÊÇcss´úÂë
 body{
font-size:12px;
}
.contextMenu{
filter:alpha(opacity=80);
opacity:0.8;
border:1px #0033FF solid;
background-color:#0099CC;
cursor:pointer;
width:120px;
position:absolute;
top:0;
left:0;
font-size:12px;
}
.cmddiv{
padding:2px;
border-bottom:1px #00FF99 dotted;
}
»¹ÓÐjavascript´úÂë
 window.onload=function(){
var contextMenu;
var buttons=['²Ëµ¥1','²Ëµ¥2','²Ëµ¥3','²Ëµ¥4'];
window.document.body.oncontextmenu=function(e){
var xy=getXY(e);
if(typeof contextMenu!="object"){
contextMenu=document.createElement("div");
for(var i=0;i<buttons.length;i++){
var div=document.createElement("div");
var cmd=document.createTextNode(buttons[i]);
div.eventDiv=i;
div.className="cmddiv";
div.appendChild(cmd);
contextMenu.appendChild(div);
}
contextMenu.className="contextMenu";
window.document.body.appendChild(contextMenu);

contextMenu.onclick=function(e){
var e = e||window.event;
var target=e.target||e.srcElement;
alert(target.eventDiv);
}
}
contextMenu.style.display="";
contextMenu.style.top=xy.y+10+"px";
contextMenu.style.left=xy.x+10+"px";
return false;
}
window.document.body.onclick=function(){
if(typeof contextMenu=="object"){
contextMenu.style.display="none";
}
}
var getXY=function(e){
var x,y;
var e = e||window.event;
return {x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop};
}
}
 
´úÂëֻдµ½Åжϳöµã»÷µÄÊÇÄǸöÃüÁÖÁÓÚҪʵÏֵĺ¯Êý£¬»¹ÊÇÒª×Ô¼ºÐ´µÄ


Ïà¹ØÎĵµ£º

ÓÃjavascriptʵÏÖÒ³ÃæÎÞˢиüÐÂÊý¾Ý

³ÌÐòÉè¼ÆÖлᾭ³£Åöµ½Ò»ÖÖÇé¿ö£¬¾ÍÊÇÊÂÏÈÎÞ·¨µÃÖªÓû§»áÐèÒªÄÄЩÊý¾Ý£¬±ØÐë¸ù¾ÝÓû§Ñ¡ÔñºóÔÙ´Ó·þÎñÆ÷
ÖØÐÂÌáÈ¡Êý¾Ýºó·´À¡¸øÓû§¡£±ÈÈçÒ»¼òµ¥µÄÇé¿ö£¬Óû§Ñ¡ÔñÊ¡·ÝÒÔºó£¬ÎÒÃÇÁ¢¼´»áÔÚÊÐÀï±ß½«Õâ¸öÊ¡µÄËùÓÐ
ÊÐÖØÐÂÏÔʾ³öÀ´¡£ÕâÖÖÇé¿öÒ»°ãÐèÒª½«Õû¸öÒ³Ãæˢкó²Å¿ÉÒÔÖØжÁÈ¡£¬µ«ÕâÑù²»½öЧÂʲ»¸ßÍ⣬ҲÏԵò»
Ì«ÓÅÑÅ¡£Æäʵ ......

Javascript¿ª·¢Ö®jsѹËõƪ

YUI Compressor ѹËõ JavaScript µÄÄÚÈÝ°üÀ¨£º
ÒƳý×¢ÊÍ
ÒƳý¶îÍâµÄ¿Õ¸ñ
ϸ΢ÓÅ»¯
±êʶ·ûÌæ»»£¨Identifier Replacement£©
YUI Compressor °üÀ¨ÄÄЩϸ΢ÓÅ»¯ÄØ£¿
object["property"] £¬Èç¹ûÊôÐÔÃûÊǺϷ¨µÄ JavaScript ±êʶ·û£¨×¢£ººÏ·¨µÄ JavaScript ±êʶ·û——ÓÉÒ»¸ö×Öĸ¿ªÍ·£¬ÆäºóÑ¡ÔñÐԵؼÓÉÏÒ»¸ö»òÕ ......

javascript: ÕýÔò±í´ïʽ

ÕýÔò±í´ïʽ
RegExp(regexp, option)ÀàʵÏÖ,¿ÉÒÔ¼òд³É/regexp/option
option:
g: global, i: ignore case
·½·¨:string.test(regexp),
string.exec(regexp)[·µ»ØËùÓÐÆ¥ÅäµÄµØ·½], string.serch(regexp)[ÕýÔò°æµÄindexOf()],
string.replace(regexp, str|funtion), string.split(regexp)
¼òµ¥Ä£Ê½
Ôª×Ö·û:( [ {
......

À뿪»­ÃæʱµÄJavaScriptÈ·ÈÏÌáʾ

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;

onbeforeunload ʼþ²Î¿¼µØÖ·
http://msdn.microsoft.com/en-us/ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ