您的位置:首页 > Web前端 > JavaScript

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: