87,993
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JS获取对象的所有属性方法和对应的值</title>
</head>
<style type="text/css">
body,td,div,input,fieldset,legend{font-family:Verdana; font-size:12px; color:#333333; font-weight:normal;}
td{line-height:20px;}
a:link,a:visited{font-family:Verdana; font-size:12px; color:#330099; font-weight:normal; padding:0px 3px; text-decoration:none;}
a:hover,a:active{font-family:Verdana; font-size:12px; color:#FF6600; font-weight:normal; }
span{font-family:Verdana; font-size:12px; color:red; font-weight:normal; display:block; margin:0px 10px;}
.cur01{background-color:#00CCFF; color:#FF3300; font-weight:bold;}
</style>
<script type="text/javascript" language="javascript">
function getXProperty(objID){
var oID=objID
var obj=document.getElementById(oID);
var nv="";
var i=0;
document.getElementById("prolist").innerHTML="<hr size='1' color='red'>";
for(var xitem in obj){ //obj.attributes
i++;
document.getElementById("prolist").innerHTML+=(i<100 ? (i<10 ? '00'+i : '0'+i) : i)+" Name:<b> "+xitem+"</b>";
document.getElementById("prolist").innerHTML+=" -------------------- ";
eval("nv=obj."+xitem+"");
document.getElementById("prolist").innerHTML+="值:<font color=red> "+(nv==null ? '空' : nv )+"</font><br>";
}
}
</script>
<body>
<p>
<a id="link01" name="linkName01" title="link 01" href="http://www.baidu.com">百度 http://www.baidu.com</a>
<input name="btn01" type="button" onClick="javascript:getXProperty('link01');" value="获取 a 对象的所有属性方法">
</p>
<p>
<object id="xMediaPlayer" width="406" height="68" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6">
<param name="AutoStart" value="1" />
<param name="url" value="http://www.eecosway.com/pub1209363811377.mp3" />
<param name="src" value="http://www.eecosway.com/pub1209363811377.mp3" />
<param name="PlayCount" value="1" />
<param name="EnableContextMenu" value="0" />
<param name="Volume" value="100" />
<embed src="" name="MediaPlayer" type="video/x-ms-wmv" width="406" height="68" autostart="1" showcontrols="1" allowscan="1" playcount="100" enablecontextmenu="0"></embed>
</object>
<input name="btn01" type="button" onClick="javascript:getXProperty('xMediaPlayer');" value="获取 object 对象的所有属性方法">
<br>
created:2009-12-04 <br>
author: shenzhenNBA
</p>
<div id="prolist"></div>
</body>
</html>
function ClassA(){
this.a = 1;
}
ClassA.prototype = {
func: function(){
alert(this.a);
}
}
for (var item in ClassA.prototype) {
alert(item);
}
for (var item in new ClassA()) {
alert(item);
}