JavaScriptÖÐsetAttributeÓ÷¨
ÎÒÃǾ³£ÐèÒªÔÚJavaScriptÖиøElement¶¯Ì¬Ìí¼Ó¸÷ÖÖÊôÐÔ£¬Õâ¿ÉÒÔͨ¹ýʹÓÃsetAttribute()À´ÊµÏÖ£¬Õâ¾ÍÉæ¼°µ½ÁËä¯ÀÀÆ÷µÄ¼æÈÝÐÔÎÊÌâ¡£
setAttribute(string name, string value)£ºÔö¼ÓÒ»¸öÖ¸¶¨Ãû³ÆºÍÖµµÄÐÂÊôÐÔ£¬»òÕß°ÑÒ»¸öÏÖÓеÄÊôÐÔÉ趨Ϊָ¶¨µÄÖµ¡£
1¡¢ÑùʽÎÊÌâ
setAttribute(class, value)ÖÐclassÊÇÖ¸¸Ä±äclassÕâ¸öÊôÐÔ£¬ËùÒÔÒª´øÒýºÅ¡£
vName´ú±í¶ÔÑùʽ¸³Öµ¡£
ÀýÈç:
var input = document.createElement(input);
input.setAttribute(type, text);
input.setAttribute(name, q);
input.setAttribute(class,bordercss);
Êä³öʱ£º,¼´£¬input¿Ø¼þ¾ßÓÐbordercssÑùʽÊôÐÔ
×¢Ò⣺classÊôÐÔÔÚW3C DOMÖаçÑÝןÜÖØÒªµÄ½ÇÉ«£¬µ«ÓÉÓÚä¯ÀÀÆ÷²îÒìÐÔÈÔÈ»´æÔÚ¡£
ʹÓÃsetAttribute(class, vName)Óï¾ä¶¯Ì¬ÉèÖÃElementµÄclassÊôÐÔÔÚfirefoxÖÐÊÇÐеÄͨµÄ£¬µ«ÔÚIEÖÐÈ´²»ÐС£ÒòΪʹÓÃIEÄں˵Ää¯ÀÀÆ÷²»ÈÏʶclass£¬Òª¸ÄÓÃclassName£»
ͬÑù£¬firefox Ò²²»ÈÏʶclassName¡£ËùÒÔ³£Óõķ½·¨ÊǶþÕ߼汸£º
element.setAttribute(class, value); //for firefox
element.setAttribute(className, value); //for IE
2¡¢·½·¨ÊôÐÔµÈÎÊÌâ
ÀýÈ磺
var bar = document.getElementById(testbt);
bar.setAttribute(onclick, javascript:alert('This is a test!'););
ÕâÀïÀûÓÃsetAttributeÖ¸¶¨eµÄonclickÊôÐÔ£¬¼òµ¥£¬ºÜºÃÀí½â¡£
µ«ÊÇIE²»Ö§³Ö£¬IE²¢²»ÊDz»Ö§³ÖsetAttributeÕâ¸öº¯Êý£¬¶øÊDz»Ö§³ÖÓÃsetAttributeÉèÖÃijЩÊôÐÔ£¬ÀýÈç¶ÔÏóÊôÐÔ¡¢¼¯ºÏÊôÐÔ¡¢Ê¼þÊôÐÔ£¬Ò²¾ÍÊÇ˵ÓÃsetAttributeÉèÖÃstyleºÍonclickÕâЩÊôÐÔÔÚIEÖÐÊÇÐв»Í¨µÄ¡£
Ϊ´ïµ½¼æÈݸ÷ÖÖä¯ÀÀÆ÷µÄЧ¹û£¬¿ÉÒÔÓõã·ûºÅ·¨À´ÉèÖÃElementµÄ¶ÔÏóÊôÐÔ¡¢¼¯ºÏÊôÐÔºÍʼþÊôÐÔ¡£
document.getElementById(testbt).className = bordercss;
document.getElementById(testbt).style.cssText = color: #00f;;
document.getElementById(testbt).style.color = #00f;
document.getElementById(testbt).onclick= function () { alert(This is a test!); }
ÓÉ´ËÑÓÉìµÄÎÊÌâ:
Ò»¸öinputµÄtext,µ±½«html¸³ÖµÎªÄ³¸ödivµÄinnerHTMLʱ,Óöµ½Ò»¸öÏÖÏó,µ±ÔÚfirefoxÏÂʱ(IEϲ»´æÔÚ´ËÎÊÌâ), ¸³ÖµºóµÄinnerHTMLÀï²»º¬ÓÐvalue,¼´µ±ÄãÔÚÎı¾¿òÊäÈëÄÚÈݺó,ÄãÏ뽫¸³Öµ¸ødivʱ,Ö»»áµÃµ½,ÕâÀï×ÜÊǻὫvalueÇå³ý.
Õâʱ,setAttributeÆð×÷ÓÃÁË,ÔÚinputÄÚ¼ÓÉÏ:onkeyup=t
Ïà¹ØÎĵµ£º
ÕâÁ½ÌìÔÚ×öÒ»¸ö¿Ø¼þµÄʱºòÓöµ½Òª´¥·¢onchangeʼþµÄÎÊÌ⣬±¾À´ÒÔΪֵһµ©¸ü¸Ä¾Í»á´¥·¢onchangeʼþ£¬µ«Êµ¼ÊÉϲ»ÊÇÏëÏóÖеÄÄÇÑù¡£
¶ÔÓÚonBlurºÍonFocus¿ÉÒÔÖ±½Óµ÷ÓÃobject.Blur()ºÍobject.Focus()£¬µ«javascriptÖÐûÓÐobject.Changeʼþ¡£ÓÚÊǾÍÔÚÍøÉϲéÁËһϣ¬·¢ÏÖobject.fireEvent()¿ÉÒÔ´¥·¢Ê¼þ£¬Èç´¥·¢onchangeʼþÔòÊ ......
JavaScript ʱÖÓ£¨´úÂ룩:
<html>
<body onload=aaa()>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtim ......
click() ¶ÔÏó.click() ʹ¶ÔÏó±»µã»÷¡£
closed ¶ÔÏó.closed ¶ÔÏó´°¿ÚÊÇ·ñÒѹرÕtrue/false
clearTimeout(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetTimeout¶ÔÏó
clearInterval(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetInterval¶ÔÏó
confirm("ÌáʾÐÅÏ¢") µ¯³öÈ·ÈÏ¿ò£¬È·¶¨·µ»ØtrueÈ¡Ïû·µ»Øfalse
cursor:Ñùʽ ¸ü¸ÄÊó±êÑùʽ hand crosshair text wait help defa ......
ÔÌûµØÖ·£ºhttp://www.followman.com/bbs/Topic-B11-T262.aspx
JavaScript¶¯Ì¬ÏìÓ¦ATLʼþ
Ïà¹ØÌÖÂÛ:http://topic.csdn.net/t/20061012/21/5078729.html
ÖØ
µã£º½Å±¾´«¹ýÀ´µÄ¶ÔÏóÊÇIDispatch½Ó¿Ú£¬Ó¦¸ÃÓÃIDispatch::InvokeÀ´µ÷Óá£Èç¹û´«¹ýÀ´µÄÊǸöfunction£¬ÄÇôDISPID
Ϊ0£¬Èç¹ûÊǸö¶ÔÏó£¬ÄÇôҪÏÈÓÃGetIDsOfNamesµÃ ......
ä¯ÀÀÆ÷ÒѾ¿´µ½µÄ¶«Î÷¶¼´æÔÚ»º´æÎļþ¼ÐÀï¡£
½Å±¾×¢ÊÍ: µ¥ÐÐ// ¶àÐÐ/*....*/
Æô¶¯Ê±ºò¼ÓÔØfunction() window.onload= function;
alert Ìáʾ¶Ô»°¿ò alert("ÌáʾÄÚÈÝ");
promptÌáʾÊäÈë¿òprompt("ÌáʾÄÚÈÝ","ĬÈÏÖµ")£»
JavaScriptÖض¨Ïò ÔÚ×°ÔØÒ³Ãæʱ£¬²»ÄÜÔÚ×°ÔØÍêÖ ......