ÓÃjavascriptʵÏÖÒ³ÃæÎÞˢиüÐÂÊý¾Ý
³ÌÐòÉè¼ÆÖлᾳ£Åöµ½Ò»ÖÖÇé¿ö£¬¾ÍÊÇÊÂÏÈÎÞ·¨µÃÖªÓû§»áÐèÒªÄÄЩÊý¾Ý£¬±ØÐë¸ù¾ÝÓû§Ñ¡ÔñºóÔÙ´Ó·þÎñÆ÷
ÖØÐÂÌáÈ¡Êý¾Ýºó·´À¡¸øÓû§¡£±ÈÈçÒ»¼òµ¥µÄÇé¿ö£¬Óû§Ñ¡ÔñÊ¡·ÝÒÔºó£¬ÎÒÃÇÁ¢¼´»áÔÚÊÐÀï±ß½«Õâ¸öÊ¡µÄËùÓÐ
ÊÐÖØÐÂÏÔʾ³öÀ´¡£ÕâÖÖÇé¿öÒ»°ãÐèÒª½«Õû¸öÒ³Ãæˢкó²Å¿ÉÒÔÖØжÁÈ¡£¬µ«ÕâÑù²»½öЧÂʲ»¸ßÍ⣬ҲÏԵò»
Ì«ÓÅÑÅ¡£ÆäʵÓÃjavascript½áºÏ΢Èí¼þµÄXMLHTTP¶ÔÏó£¬ÎÒÃÇ¿ÉÒÔ²»ÓÃˢУ¬“ÉÔÉÔ”µÄ¾Í¿ÉÒÔ½«Êý¾Ý´Ó·þ
ÎñÆ÷É϶ÁÈ¡³öÀ´£¬ÏԵüÈרҵ£¬ÓÖ¸ßЧ¡£
ÏÂÃæÎÒÃǾÍÒÔÒ»¸öÑéÖ¤Óû§ÊÇ·ñ±»×¢²áµÄÇé¿öÀ´ÑÝʾÕâÖÖ¼¼Êõ¡£
1.Ê×ÏÈÔÚ·þÎñÆ÷ÉϽ¨Á¢Ò»¸öCheckUser.aspÎļþ£¬ÓÃÀ´¼ì²âÓû§ÊÇ·ñ´æÔÚ£¬¸ù¾ÝÓû§ÊÇ·ñ´æÔÚ·Ö±ð·´À¡0ºÍ1
u_name=Request.QueryString("u_name")
if u_name ´æÔÚ then
Response.write "0"
else
Response.write "1"
end if
2.¿Í»§¶ËHTMLÉè¼Æ:
Ò»¡¢JavaScript´úÂë
<script language=javascript>
function check_user_exists(form){
u_name=form.u_name.value;
if (u_name==null||u_name==''){
alert("ÇëÄúÊäÈëÓû§Ãû");
return false;
}
infoBoard=document.getElementById("checkInfo");
infoBoard.innerText='²éѯÖÐ...';
myurl=location.protocol+"//"+location.hostname+"/CheckUser.asp?u_name="+u_name;
retCode=openUrl(myurl);
switch(retCode){
case "-2":
infoBoard.innerHTML='<font color=red>±§Ç¸</font>,²éѯʧ°Ü';break;
case "1":
infoBoard.innerHTML='<font color=red>¹§Ï²</font>,'+u_name+'¿ÉÒÔʹÓÃ';break;
case "0":
infoBoard.innerHTML='<font color=red>±§Ç¸</font>£¬Óû§Ãû'+u_name+'ÒѾ±»Ê¹ÓÃ';
}
return;
}
function openUrl(url){
var objxml=new ActiveXObject("Microsoft.XMLHttp")
objxml.open("GET",url,false);
objxml.send();
retInfo=objxml.responseText;
if (objxml.status=="200"){
return retInfo;
}
else{
return "-2";
}
}
</script>
¶þ¡¢HTML±íµ¥Éè¼Æ:
<form name=form1 action="XXXX.asp" method="post">
<input type=text name=u_name><span id="checkInfo"></span><input type=button name=checkuser
value="¼ì²âÓû§ÊÇ·ñ´æÔÚ" onClick="check_user_exists(this.form);">
</form>
¾¹ýÒÔ
Ïà¹ØÎĵµ£º
< a href =
"#"
onClick =
"javascript:window.external.AddFavorite(document.URL,document.title);return
false"
rel=
"sidebar"
> Êղر¾Ò³ </ a >
È¡µÃµ±Ç°Ò³µÄURL: document.URL
È¡µÃµ±Ç°Ò³µÄtitle: document.title
ʵÏÖÔÚFirefoxÖГÊÕ
²Ø±¾Ò ......
ÎÒÏëʹÓùýajaxµÄ¶¼³£¼ûÕâÑùµÄ´úÂ룺
<a href="javascript:doTest2();void(0);">here</a>
µ«Õâ¶ùµÄvoid(0)¾¿¾¹ÊǺκ¬ÒåÄØ£¿
JavascriptÖÐvoidÊÇÒ»¸ö²Ù×÷·û£¬¸Ã²Ù×÷·ûÖ¸¶¨Òª¼ÆËãÒ»¸ö±í´ïʽµ«ÊDz»·µ»ØÖµ¡£
void ²Ù×÷·ûÓ÷¨¸ñʽÈçÏ£º
1. javascript:void (expression)
2. javascript:void expression
expr ......
JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
JavaScript can put dynamic text into an HTML page - A Ja ......
ÃÜÂëÒѾÊÇÎÒÃÇÉú»î¹¤×÷Öбز»¿ÉÉٵŤ¾ß,µ«Ò»¸ö²»°²È«µÄÃÜÂëÓÐÓÖÓпÉÄÜ»á¸øÎÒÃÇÔì³É²»±ØÒªµÄËðʧ¡£×÷ΪÍøÕ¾Éè¼ÆÕß,Èç¹ûÎÒÃÇÔÚÍøÒ³ÖÐÄܶÔÓû§ÊäÈëµÄÃÜÂë½øÐа²È«ÆÀ¹À,²¢ÏÔʾ³öÏàÓ¦µÄÌáʾÐÅÏ¢,ÄÇô¶ÔÓû§ÉèÖÃÒ»¸ö°²È«µÄÃÜÂ뽫Óкܴó°ïÖú¡£Í¬Ê±Ò²Ê¹µÃÍøÕ¾¸ü¾ßÈËÐÔ»¯,¸üÓÐÎüÒýÁ¦.
ʲôÊÇÒ»¸ö°²È«µÄÃÜÂëÄØ ......