TO: wsj(骆驼)(从麻木中苏醒) 谢谢您! 我刚才按您所提供的两种写法用一个VBSCRIPT函数试了一下都还存在问题 <script language="vbscript"> <!-- function HdReload() parent.document.all("HdMain").document.all("HdMain_left").contentWindow.location.reload() end function --> </script> 点击HdTop里页面的“刷新”掉HdReload()函数,总是提示“缺少对象”,是怎么一会事?
而且我现在是不只想刷新页面,而且想在上框架HdTop src="DefaultOrgTop.asp"中点击一个按钮Hd_Location变可连接一个页面到主框架HdMain中的主窗口(HdMain_Main中)我这样写也是不行的<script language="vbscript"> function Hd_Location() parent.document.all("HdMain").document.all("HdMain_Main").contentWindow.location.src="DefaultPerson.asp" end function </script>请各位指点一下正确的写法该怎么写?
parent.document.all("HdMain").document.all("HdMain_left").contentWindow.location.reload()
parent.document.all("HdMain").HdMain_left.location.reload()
谢谢您!
我刚才按您所提供的两种写法用一个VBSCRIPT函数试了一下都还存在问题
<script language="vbscript">
<!--
function HdReload()
parent.document.all("HdMain").document.all("HdMain_left").contentWindow.location.reload()
end function
-->
</script>
点击HdTop里页面的“刷新”掉HdReload()函数,总是提示“缺少对象”,是怎么一会事?
function Hd_Location()
parent.document.all("HdMain").document.all("HdMain_Main").contentWindow.location.src="DefaultPerson.asp"
end function
</script>请各位指点一下正确的写法该怎么写?
一样!)
iframe(frame)比较特殊,用name,会认为是一个window对象,用id则会认为是页面中的一个元素.而在此出,iframe框架指向的页面即 src 代表是的 iframe 的一个属性,所以,这里应该把 iframe当成一个叶面元素,股应该用ID,改变src即可.
我以前总喜欢Name和Id同名,我现在改变一下
我有一个页面(defaultMain.asp)分三个框架
上框架Name="HdTop" Id="HdTopId" src="DefaultOrgTop.asp"
主框架Name="HdMain" Id="HdMainId" src="DefaultOrgMain.asp"
下框架Name="HdBottom" Id="HdBottomId" src="DefaultOaBottom.asp" 我在主框架HdMain的页面DefaultOrgMain.asp又分了三个浮动窗口
左窗口Name="HdMain_Left" Id="HdMain_LeftId" src="DefaultOrgMain_left.asp"
主窗口Name="HdMain_Main" Id="HdMain_MainId" src="DefaultOrgMain_Main.asp"
右窗口Name="HdMain_Right" Id="HdMain_RightId" src="DefaultOrgMain_Right.asp"我现在想在上框架Name="HdTop" Id="HdTopId" src="DefaultOrgTop.asp"页面中点击一按钮
onclick="HdReload()"主窗口Name="HdMain_Main" Id="HdMain_MainId"中更换新的页面或刷新该怎么写?
<script language="vbscript">
function Hd_Location()
parent.document.all("HdMain").HdMain_MainId.src="DefaultPerson.asp"
或
parent.document.all("HdMain").document.HdMain_MainId.src="DefaultPerson.asp"
或
parent.document.all("HdMain").document.HdMain_MainId.Location.src="DefaultPerson.asp"end function
</script>
都是没有效果的请看看,正确的写法到底该怎么写??
<button onclick="document.ifrm.location.href="rightpage.asp";">改变框架页 </button>测试通过!现在我在对上面做一个解释!
A, APPLET, attribute, BUTTON, EMBED, FORM, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, LINK, MAP, OBJECT, RT, RUBY, SELECT, TEXTAREA可以这么简单理解它们的使用区别:id用于DHTML,即客户端脚本。而name则通常用在服务器端,例如Request.form("")中就要用name。
你用<input name=myinput id=myinput>中,在客户端
<script>
alert(myinput.value)//这里是id
</script>
而提交后,用Request.form("myinput"),这里就是name。
id可以直接使用就得到对象,name的话一定要使用document.all.name来得到对象,现在提倡使用id,不过为了和以前兼容,可以两者都使用,而且名字也一样。上面的说法其实有点问题:只要把 docuent.ifrm 替换为 frm 一样可以可通过。为什么 改变src不行呢?因为 src只是一个客户端改变其属性,(就相当于 你动态改变一个 表格颜色),并不与服务器打交道,所以得不到你想要的结果。但是改变 location.href 就相当于刷新叶面的效果(相应服务器)。我们可以通过重新指定一个 叶面的 location.href 来达到刷新叶面并改变连接的效果。
请看:<iframe src="toppage.asp" name="ifrm" id="frm" width=100 height=100></iframe>
<button onclick="aa()">改变框架页 </button>
<script>
function aa(){
frm.src="rightpage.asp";
alert("你的框架页中的src已经改为"+frm.src+";但叶面没刷新,所以没有变化")
}
</script><iframe src="toppage.asp" name="ifrm" id="frm" width=100 height=100></iframe>
<button onclick="document.ifrm.location.href="rightpage.asp";">改变框架页 </button>
<iframe src="toppage.asp" name="ifrm" id="frm" width=100 height=100></iframe>
<button onclick="document.ifrm.location.href="rightpage.asp";">改变框架页 </button>对frame 一样:请看例子:
allpage.asp(包含框架页):
<html><head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head><frameset rows="64,*">
<frame name="banner" scrolling="no" noresize target="contents" src="toppage.asp">
<frameset cols="150,*">
<frame name="contents" target="main" src="leftpage.asp">
<frame name="main" src="rightpage.asp">
</frameset>
<noframes>
<body> <p>此网页使用了框架,但您的浏览器不支持框架。</p> </body>
</noframes>
</frameset></html>toppage.asp:<html><head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>this is the top page</title>
<base target="contents">
</head><body><p>this is the top page</p>
<button onclick="parent.contents.location.href='rightpage.asp'">改变左边窗口连接</button>
</body></html>
rightpage.asp:<html><head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>this is right page</title>
</head><body><p>this is right page</p></body></html>
leftpage.asp:<html><head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>this is the left page</title>
<base target="main">
</head><body><p>this is the left page</p></body></html>
看看就知道了:
原理我明白了,但是我怎么写都怎么错!按上面的frame和iframe的划分,通过的写法该怎么写???
</head><frameset rows="145,*">
<frame name="banner" scrolling="no" noresize target="contents" src="top.htm">
<frameset cols="210,*">
<frame name="contents" target="main" src="left.htm">
<frame name="main" src="right.htm">
</frameset>
<noframes>
<body> <p>此网页使用了框架,但您的浏览器不支持框架。</p> </body>
</noframes>
</frameset></html>top.htm:<head>
<title>this is the top page</title>
<base target="contents">
</head><body><p>this is the top page</p><button onclick="parent.main.document.ifrm.document.location.href='file:///c:/windows/desktop/test/left.htm'">ttt</button><button onclick="alert(parent.main.frm.document.location.href)">显示ifrm路径</button>
<button onclick="alert(parent.main.document.ifrm.document.location.href)">显示ifrm路径</button>
你只要将ttt终的href 改为 alert() 终的东西就可以了
</body></html>left.htm:<html><head>
<base target="main">
</head><body><p>this is the left page</p></body></html>right.htm:<html>
<body><p>this is the right page</p>
<iframe name="ifrm" id="frm" src="top.htm"></iframe>
</body></html>
肯定是你的路径写的有问题。你将上面的文件保存到桌面 test 文件夹中,试试看。你要改文件保存路径,页的改 程序。
如果在网站中就不会存在这个问题。