javascript ÖеÄinnerHTMLµÄÓ÷¨
javascriptÖÐinnerHtmlÓ÷¨
2009-04-21 22:52
<html>
<head>
<script language="javascript">
function Test(){
var str="";
str+="Hello,";
str+="This is a Test!<br />";
str+="I Love you;<br />";
str+="I Love you,too!";
p.innerHTML=str+"<br /><br />"+Math.random();
setTimeout('Test();',1000);
}
</script>
</head>
<body onload=Test()>
<span id="p"></span>
</body>
</html>
innerTEXTÓëinnerHTMLµÄÇø±ð£º
innerHTML×Ô´øÁËÓï·¨¼ì²é¹¦ÄÜ,Ëû»á×Ô¶¯°Ñ²»ÍêÕûµÄHTML´úÂë²¹³äÍêÕû.ÔËÐÐÈçϵÄÒ»¸ö²âÊÔ´úÂë¾Í¿ÉÒÔ·¢ÏÖÁË.
document.getElementById("AlbumList").innerHTML="<table><tr>";
alert(document.getElementById("AlbumList").innerHTML);
Ëû»á×Ô¶¯°ÑÎҵĴúÂëÀïÃæÌí¼ÓÁË<tbody>ºÍ</tr></table>µÈ±ê¼Ç.ÉñÆæ!!!
ËùÒÔÔÚÍøÒ³ÖÐ,ÎÒÃǾ³£ÕâÑùÓÃ;
<div id="content"></div>
<script language="javascript">
document.getElementById("content").innerHTML=" ÐèÏÔʾµÄÄÚÈÝ "
</script>
ÕâÑù¾Í»áÔÚid ÊÇcontentµÄ±ê¼ÇÄÇÀïÏÔʾ"ÐèÏÔʾµÄÄÚÈÝ";
Õâ¸ö¿ÉÒÔÓÃÔÚÏÔʾһƪÎÄÕµÄÕªÒªµÄ²¿·Ö,·ÀÖ¹½«´øÓÐHTML±ê¼ÇµÄÎÄÕÂÖеĴúÂë½Øµô±ê¼ÇµÄ½áÊø²¿·Ö,
e,g:
str="<a href=#/
>ɳĮÖеÄÂÌÖÞ</a><img src=image.jpg>"
left(str,60)ÔòÊÇ"<a href=#/
>ɳĮÖеÄÂÌÖÞ</a><img src=image"
<div id="content"></div>
<script language="javascript">
document.getElementById("content").innerHTML="left(str,60) "
</script>
innerHTML£¬ÊÇÔÚ¿éÖмÓhtml´úÂ룻innerText ÔÚ¿éÖмÓÎÄ×Ö
¡£ (×¢Òâ´óСд)
innerText ÊôÐÔÔÚ
Ïà¹ØÎĵµ£º
±Õ°ü£¨closure£©ÊÇJavascriptÓïÑÔµÄÒ»¸öÄѵ㣬ҲÊÇËüµÄÌØÉ«£¬ºÜ¶à¸ß¼¶Ó¦Óö¼ÒªÒÀ¿¿±Õ°üʵÏÖ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄѧϰ±Ê¼Ç£¬¶ÔÓÚJavascript³õѧÕßÓ¦¸ÃÊǺÜÓÐÓõġ£
Ò»¡¢±äÁ¿µÄ×÷ÓÃÓò
ÒªÀí½â±Õ°ü£¬Ê×ÏȱØÐëÀí½âJavascriptÌØÊâµÄ±äÁ¿×÷ÓÃÓò¡£
±äÁ¿µÄ×÷ÓÃÓòÎ޷ǾÍÊÇÁ½ÖÖ£ºÈ«¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿¡£
JavascriptÓïÑÔµÄÌØÊâÖ®´¦£¬¾ÍÔÚÓ ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dragÀà</title ......
javascriptÄÚ´æ鶵ÄÎÊÌâÒ»Ö±ÒÔÀ´¶¼²»Êܵ½´ó¼ÒµÄÖØÊÓ£¬ÔÒòÊǶÔÓû§µÄÓ°ÏìûÓÐ̫ʵ¼ÊµÄ±íÏÖ£¬»òÐí½ü¼¸ÄêÄڴ淢չѸËÙ¡£½Å±¾ÄÚ´æÔÙй¶Ҳ²»»áÓÐÌ«´óÓ°Ïì¡£
µ±È»×÷Ϊǰ¶Ë¿ª·¢µÄͬѧÃÇ£¬¾Í²»ÄÜÓÐÕâÑùµÄ½ÄÐÒÐÄÀí¡£³öÏÖmemory leaksºÜ´ó³Ì¶ÈÉÏÊÇÒòΪ³ÌÐòµÄ²»³ÉÊìºÍ±àÂ벻̫¹æ·¶Ôì³ÉµÄ¡£²»¹ý£¬ÕâÀï¾Í²»ËµÈçºÎ³öÏÖÎÊÌâµÄ£¬¶ÔÎÊÌâ ......
1¡£½â¾ö2000ÎÊÌâ
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
2¡£¼ì²éÈÕÆÚÊÇ·ñºÏ·¨
// µ±ÊäÈë²ÎÊýΪisDate(dd,mm,ccyy)ʱ£¬±íʾҪ¼ì²éÄ꣬Ô£¬ÈÕ
// µ±ÊäÈë²ÎÊýΪisDate(dd,mm) ±íʾĬÈÏÄêΪµ±Ç°Äê
// µ±ÊäÈë²ÎÊýΪisDate(dd) ±íʾĬÈÏÄ꣬ÔÂΪµ±Ç°ÄêÔÂ
......
<input type=button onclick="aaa();" value="È·¶¨">
<iframe name="frame1">
<script language=javascript>
function aaa()
{
docume ......