JavascriptÔÚÍøÒ³µÄÒ³Ãæ¼ÓÔØʱִÐеÄ˳Ðò
Ò»¡¢ÔÚHTMLÖÐǶÈëJavasriptµÄ·½·¨
1¡¢Ö±½ÓÔÚJavascript´úÂë·ÅÔÚ±ê¼Ç¶Ô<script>ºÍ</script>Ö®¼ä
2¡¢ÓÉ<script. />±ê¼ÇµÄsrcÊôÐÔÖƶ¨ÍⲿµÄjsÎļþ
3¡¢·ÅÔÚʼþ´¦Àí³ÌÐòÖУ¬±ÈÈ磺<p nclick="alert('ÎÒÊÇÓÉonclickʼþÖ´ÐеÄJavascript')">µã»÷ÎÒ</p>
4¡¢×÷ΪURLµÄÖ÷Ì壬Õâ¸öURLʹÓÃÌØÊâµÄJavascript£ºÐÒ飬±ÈÈ磺<a href="javascript.:alert('ÎÒÊÇÓÉjavascript.:ÐÒéÖ´ÐеÄjavascript')">µã»÷ÎÒ</a>
5¡¢ÀûÓÃjavascript±¾ÉíµÄdocument.write()·½·¨Ð´ÈëеÄjavascript´úÂë
6¡¢ÀûÓÃAjaxÒì²½»ñÈ¡javascript´úÂ룬ȻºóÖ´ÐÐ
µÚ3Öֺ͵Ú4ÖÖ·½·¨Ð´ÈëµÄJavascriptÐèÒª´¥·¢²ÅÄÜÖ´ÐУ¬ËùÒÔ³ý·ÇÌرðÉèÖ㬷ñÔòÒ³Ãæ¼ÓÔØʱ²»»áÖ´ÐС£
¶þ¡¢JavascriptÔÚÒ³ÃæµÄÖ´ÐÐ˳Ðò
1¡¢ Ò³ÃæÉϵÄJavascript´úÂëÊÇHTMLÎĵµµÄÒ»²¿·Ö£¬ËùÒÔJavascriptÔÚÒ³Ãæ×°ÔØʱִÐеÄ˳Ðò¾ÍÊÇÆäÒýÈë±ê¼Ç<script. />µÄ³öÏÖ˳Ðò£¬ <script. />±ê¼ÇÀïÃæµÄ»òÕßͨ¹ýsrcÒýÈëµÄÍⲿJS£¬¶¼ÊÇ°´ÕÕÆäÓï¾ä³öÏÖµÄ˳ÐòÖ´ÐУ¬¶øÇÒÖ´Ðйý³ÌÊÇÎĵµ×°ÔصÄÒ»²¿·Ö¡£
2¡¢Ã¿¸ö½Å±¾¶¨ÒåµÄÈ«¾Ö±äÁ¿ºÍº¯Êý£¬¶¼¿ÉÒÔ±»ºóÃæÖ´ÐеĽű¾Ëùµ÷Óá£
3¡¢±äÁ¿µÄµ÷Ó㬱ØÐëÊÇÇ°ÃæÒѾÉùÃ÷£¬·ñÔò»ñÈ¡µÄ±äÁ¿ÖµÊÇundefined¡£
<script. type="text/javscrpt">//<![CDATA[
alert(tmp); //Êä³ö undefined
var tmp = 1;
alert(tmp); //Êä³ö 1
//]]></script>
4¡¢Í¬Ò»¶Î½Å±¾£¬º¯Êý¶¨Òå¿ÉÒÔ³öÏÖÔÚº¯Êýµ÷ÓõĺóÃ棬µ«ÊÇÈç¹ûÊÇ·Ö±ðÔÚÁ½¶Î´úÂ룬ÇÒº¯Êýµ÷ÓÃÔÚµÚÒ»¶Î´úÂëÖУ¬Ôò»á±¨º¯Êý䶨Òå´íÎó¡£
<script. type="text/javscrpt">//<![CDATA[
aa(); //ä¯ÀÀÆ÷±¨´í
//]]></script>
<script. type="text/javscrpt">//<![CDATA[
aa(); //Êä³ö 1
function aa(){alert(1);}
//]]></script>
5¡¢document.write()»á°ÑÊä³öдÈëµ½½Å±¾ÎĵµËùÔÚµÄλÖã¬ä¯ÀÀÆ÷½âÎöÍêdocumemt.write()ËùÔÚÎĵµÄÚÈݺ󣬼ÌÐø½âÎödocument.write()Êä³öµÄÄÚÈÝ£¬È»ºóÔÚ¼ÌÐø½âÎöHTMLÎĵµ¡£
<script. type="text/javascript">//<![CDATA[
document.write('<script. type="text/javascript" src="test.js"><\/script>');
document.write('<script. type="text/javascript">');
document.write('alert(2);'
Ïà¹ØÎĵµ£º
×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæʵÃæÄ¿¡£
¡¡¡¡Ò»¡¢Ê²Ã´ÊDZհü£¿
¡¡¡¡“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐ ......
Ò»¡¢ÐÂÔöÒ»¸öoption
var sel=document.getElementById("selectµÄid");
var op=document.createElement("option");
op.value=Öµ;
op.text=ÏÔʾÎı¾;
sel.add(op);
¶þ¡¢É¾³ýÒ»¸öoption
var sel=document.getElementById("typelist");
if(sel.selectedIndex==-1)
alert("ÇëÑ¡ ......
<html>
<body>
<table width="200" border="1" id="tb">
<tr id="r1">
<td><input type="checkbox" name="ck" value="1"></td>
<td>abc</td>
</tr>
</table>
<p>
<input type="button" onClick="add();" value="add"/> ......
תÔØ:JavaScript»ñÈ¡Ò³Ãæ¿í¶È¸ß¶È´óÈ«
µØÖ·:http://www.cnblogs.com/wcg249165510/archive/2009/02/20/1394749.html
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.offsetWidth(°üÀ¨±ßÏߵĿí)
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight(° ......
×öJava¿ª·¢µÄÈ˶¼ÖªµÀ,ÔÚJavaÖÐÓÐXXXFormat(±ÈÈçSimpleDateFormat)Àà¿ÉÒÔ°ïÖúÎÒÃǵõ½ÏëÒªµÄÊý¾Ý¸ñʽ.ÔÚJavaScriptÖÐûÓÐÕâÑùµÄ¶«Î÷,ËùÒÔÎÒÃÇÐèÒªÓÃÁíÒ»ÖÖ·½·¨µÃµ½ÎÒÃÇÏëÒªµÄ¶«Î÷.´úÂëÈçÏÂ:
<html>
<head>
<title>Test</title>
<mce:script type="text/javascript" language="javascri ......