javaScripte获取网页上的对象属性
2010-11-14 02:08
369 查看
<!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=gb2312" />
<title>请输入个人资料</title>
<script>
function showProps(){
var i;
document.write("<h1>文档对象属性<h1/><hr/>");
document.write("<h2>基本页面属性<h2/>");
document.write("Location="+document.location+"<br/>");
document.write("文档标题="+document.title+"<br/>");
document.write("URL="+document.location+"<br/>");
document.write("文档颜色");
document.write("背景颜色="+document.bgColor+"<br/>");
document.write("文本颜色="+document.fgColor+"<br/>");
document.write("链接颜色="+document.linkColor+"<br/>");
document.write("最后修改时间="+document.lastModified+"<br/>");
if(document.forms.length>0)
{
document.write("<h2>表单</h2>");
document.write("表单数="+document.forms.length+"<br/>");
for(i=0;i<document.forms.length;i++)
{
document.write("forms["+i+"]="+document.forms[i].name+"<br/>");
document.write("表单元素数目:"+document.forms[i].length+"<br/>");
for(j=0;j<document.forms[i].elements.length;j++){
document.write("表单标记名:"+document.forms[i].elements[j]+"<br/>")
}
}
}
}
</script>
</head>
<body>
<form action="#" method="get" id="frmInfo" name="frmInfo">
<label for="userName">姓 名:</label><input id="name" name="name" type="text"/><br/>
<label for="sex">性别:</label><input type="radio" id="male" name="sex" value="男">男</input>
<input type="radio" id="female" name="female" value="女">女</input><br/>
<label>学历:</label>
<select name="select" id="select">
<option value="高中及以下">高中及以下</option>
<option value="中专">中专</option>
<option value="大专">大专</option>
<option value="本科">本科</option>
<option value="硕士">硕士</option>
<option value="博士">博士</option>
</select>
<br />
<label>爱好:</label>
<input type="checkbox" name="Favorite" id="Favorite1" value="读书"/>
<input type="checkbox" name="Favorite" id="Favorite2" value="美食"/>
<input type="checkbox" name="Favorite" id="Favorite3" value="旅游"/>
<input type="checkbox" name="Favorite" id="Favorite4" value="音乐"/>
<br/>
<textarea name="textarea" id="textarea" cols="40"> </textarea><br />
<input type="submit" value="提交" tabindex="3"/><input type="reset" value="重置" tabindex="4" />
</form>
<script type="text/javascript">
showProps();
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>请输入个人资料</title>
<script>
function showProps(){
var i;
document.write("<h1>文档对象属性<h1/><hr/>");
document.write("<h2>基本页面属性<h2/>");
document.write("Location="+document.location+"<br/>");
document.write("文档标题="+document.title+"<br/>");
document.write("URL="+document.location+"<br/>");
document.write("文档颜色");
document.write("背景颜色="+document.bgColor+"<br/>");
document.write("文本颜色="+document.fgColor+"<br/>");
document.write("链接颜色="+document.linkColor+"<br/>");
document.write("最后修改时间="+document.lastModified+"<br/>");
if(document.forms.length>0)
{
document.write("<h2>表单</h2>");
document.write("表单数="+document.forms.length+"<br/>");
for(i=0;i<document.forms.length;i++)
{
document.write("forms["+i+"]="+document.forms[i].name+"<br/>");
document.write("表单元素数目:"+document.forms[i].length+"<br/>");
for(j=0;j<document.forms[i].elements.length;j++){
document.write("表单标记名:"+document.forms[i].elements[j]+"<br/>")
}
}
}
}
</script>
</head>
<body>
<form action="#" method="get" id="frmInfo" name="frmInfo">
<label for="userName">姓 名:</label><input id="name" name="name" type="text"/><br/>
<label for="sex">性别:</label><input type="radio" id="male" name="sex" value="男">男</input>
<input type="radio" id="female" name="female" value="女">女</input><br/>
<label>学历:</label>
<select name="select" id="select">
<option value="高中及以下">高中及以下</option>
<option value="中专">中专</option>
<option value="大专">大专</option>
<option value="本科">本科</option>
<option value="硕士">硕士</option>
<option value="博士">博士</option>
</select>
<br />
<label>爱好:</label>
<input type="checkbox" name="Favorite" id="Favorite1" value="读书"/>
<input type="checkbox" name="Favorite" id="Favorite2" value="美食"/>
<input type="checkbox" name="Favorite" id="Favorite3" value="旅游"/>
<input type="checkbox" name="Favorite" id="Favorite4" value="音乐"/>
<br/>
<textarea name="textarea" id="textarea" cols="40"> </textarea><br />
<input type="submit" value="提交" tabindex="3"/><input type="reset" value="重置" tabindex="4" />
</form>
<script type="text/javascript">
showProps();
</script>
</body>
</html>
相关文章推荐
- javascript获取未知对象属性以及属性值
- javascript获取函数名称、函数参数、对象属性名称的代码实例
- 获取JavaScript对象长度,获取JavaScript对象第N个属性
- 网页编程--JavaScript之document对象获取节点(三种方式)
- javascript获取函数名称、函数参数、对象属性名称的代码实例
- javascript中获取一个对象的属性名…
- JavaScript中获取未知对象属性的代码
- js中获取一个对象里面的方法和属性的javascript
- 获取JavaScript自定义对象的所有属性和值
- TerraExplorer 6.6 api for javaScript 中的Points无法获取该对象的属性和使用其所持有方法
- JavaScript之面向对象学习二(原型属性对象与in操作符)获取对象中所有属性的方法
- JavaScript 获取对象中第一个属性
- 在javascript中获取一个对象内属性的个数
- JavaScript-通过属性名,获取对象相关属性的值
- 谷歌浏览器不支持javascript 属性对象获取问题
- Javascript获取对象的属性名及对应的属性值
- JavaScript 获取对象属性和方法
- JavaScript中获取未知对象属性的代码
- java基础64 JavaScript中的Arrays数组对象和prototype原型属性(网页知识)
- javascript 将变量值作为对象属性 获取对象对应的值