学习要靠积累。。。。。。。。。。。
1、
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<h1>Example Heading</h1>
<hr />
<p>This is a <em>paragraph</em>. It is only a <em>paragraph.</em></p>
<p>Yet another <em>paragraph.</em></p>
<p>This final <em>paragraph</em> has <em id="special">special emphasis.</em></p> <hr />
<script type="text/javascript">
// document.write('ok')//**********若不放在函数里会自动执行
var i,origLength;
origLength = document.all .length;
document.write( origLength);
for (i = 0; i < origLength; i++)
{
document.write(" document.all ["+i+"]="+ document.all [i].tagName+"<br />"); //tagName是标签的名字如html
}
</script>
</body>
</html>
小结:javascript 放的位置不对,document.all.length就不一样
2、
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style type="text/css"> #docid{ height:400px; width:400px; background-color:#999;} </style>
</head>
<body><div id="docid" onClick="bgcolor()"></div> </body> //怎样给div设置的样式,在样式表中。
<script language="javascript" type="text/javascript">
function bgcolor()
{
// document.all ["docid"].style.backgroundColor="#00eeff"
document.getElementById("docid").style.backgroundColor = "#1eeeee";
}
</script>
</html>
小结:积累基本用法
3、
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Document.All Example #2</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script language="javascript" type="text/javascript">
function left()
{
document.getElementById("heading1").align="left";
}
function bigger()
{
document.all["heading1"].style.fontSize="xx-large";
}
</script>
</head>
<body> <!-- Works in Internet Explorer and compatible -->
<h1 id="heading1" align="center" style="font-size: larger;">DHTML Fun!!!</h1>
<form name="testform" id="testform" action="#" method="get"> <br /><br />
<input type="button" value="Align Left" onclick="left()" />
<br /><br />
<input type="button" value="Bigger" onclick=" bigger()" />
<input type="button" value="Smaller" onclick=" document.all [heading1].style.fontSize=xx-small;" />
<br /><br /> <input type="button" value="Red" onclick=" document.all [heading1].style.color=red;" />
<input type="button" value="Blue" onclick=" document.all [heading1].style.color=blue;" />
<br /><br /> <input type="text" name="userText" id="userText" size="30" />
<input type="button" value="Change Text" onclick=" document.all [heading1].innerText=document.testform.userText.value;" />
</form>
</body>
</html>
小结:总结基本用法