使用document.write()向输出流定文本及HTML
<html>
<body>
<script type="text/javas
document.write("Hello World!")
document.write("<br><input type='text' name='MyName' value='33333333'>")
</script>
</body>
</html>
------------------------------------------------------------------------------------------------
返回当前文档的标题、URL、referrer、服务器域名
<html>
<head>
<title>My title</title>
</head>
<body>
该文档的标题、url、referrer、域名分别是:
<script type="text/javas
document.write("<br>"+document.title+"<br>")
document.write(document.URL+"<br>")
document.write(document.referrer+"<br>")
document.write(document.domain+"<br>")
</script>
</body>
</html>
---------------------------------------------------------------------------------
使用 getElementById()
<html>
<head>
<script type="text/javas
function getValue()
{
var x=document.getElementById("myHeader")
alert(x.innerHTML)
}
</script>
</head>
<body>
<h1 id="myHeader" on
<p>点击标题,会提示出它的值。</p>
</body>
</html>
----------------------------------------------------------------------
使用 getElectmentByName()
<html>
<head>
<script type="text/javas
function getElements()
{
var x=document.getElementsByName("myInput");
alert(x.length);
}
</script>
</head>
<body>
<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<br />