JavaScript对象
<script language="javascript">
//js中定义了一个构造器
function Person(){
}
var person1=new Person();
person1.age=18;
person1.name="wangyec";
alert(person1.age+"-----"+person1.name);
//还可以通过以下方式来访问对象的属性
alert(person1["name"]+"------->"+person1["age"]);
//还可以动态的生成JavaScript代码
eval("alert(person1.name);");
//动态生成js的好我们可以控制代码生成
var x="name";
eval("alert(person1."+x+");");
//另外在动态生成代码时,我试了以下似乎只可以以点的方式来访问属性。
</script>
html frameSet
<html>
<head>
</head>
<frameset rows="50%,50%">
<frame name="top" src="IP的验证.html">
<frame name="bottom" src="javascript_1.html">
</frameset>
<>
</html>
操作frame
//在top 页面中刷新bottom页面的方法1
<input type="button" value="刷新" onclick="window.parent.frames[1].location.reload()"/>
//在top 页面中刷新bottom页面的方法2
<input type="button" value="刷新" onclick="parent.frames.bottom.location.reload()"/>
//在top 页面中刷新bottom页面的方法3
<input type="button" value="刷新" onclick="parent.frames['bottom'].location.reload()"/>
//在top 页面中刷新bottom页面的方法4
<input type="button" value="刷新" onclick="parent.frames.item(1).location.reload()"/>
//在top 页面中刷新bottom页面的方法5
<input type="button" value="刷新" onclick="parent.frames.item('bottom').location.reload()"/>
//在top 页面中刷新bottom页面的方法6
<input type="button" value="刷新" onclick="parent.bottom.location.reload()"/>
//在top 页面中刷新bottom页面的方法7
<input type="button" value="刷新" onclick="parent['bottom'].location.reload()"/>
本文介绍了JavaScript中对象的创建及属性访问方法,并演示了如何使用eval动态生成代码。此外,还展示了如何在HTML FrameSet中操作不同帧,实现刷新等交互功能。
798

被折叠的 条评论
为什么被折叠?



