屋内有鬼2:框架页刷新问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/05 21:46:56
一个框架集(index.asp),包含两个框架:left.asp(左),main.asp(主框架),在左框架页中点击,详细内容出现在主框架页中。
我现在需要从left点击a1.asp(在main中显示),然后提交到a2.asp(新窗口,打开以后关闭a1)中,a2中进行数据库的操作以后,我想reload主框架页,如何实现?
我在a1中用window.opener.parent.frames["main"].location.reload();可以,在a2中就不可以,可能因为a2跟index.asp没有什么关系了,这种情况怎么办?

你打开的a2是不是弹出窗口? 如果是请使用方法1,2.. ,不是请使用方法A,B..)

方法1:
如果a2.asp是用 window.showModalDialog 方法打开的窗口请传递self对象或top对象
showModalDialog('a2.asp',self ......)
然后在a2的脚本里写上
var oMyParentWindow = window.dialogArguments;
oMyParentWindow.location.reload()
self.close()

方法2:
如果a2是用window.open 方法打开的窗口请使用
window.opener.location.reload()
self.close()

方法A:
给两个框架起名:
<frame name="_myLeftFrame" id="_myLeftFrame" src="left.asp">
<frame name="_myMainFrame" id="_myLeftFrame" src="main.asp">
然后再脚本里可以这样调用
top._myMainFrame.location.href="main.asp"

方法B
在a2.asp的<%%>中调用
response.redirect("main.asp")

其他参考:
1. left.asp 中如果不想给每个链接加上target="_myMainFrame" 请在<head></head>之间加上:
<base target="_myMainFrame">
2. 页面跳转使用 window.open(url,"_self")不如使用self.location.href=url;
同理window.open(url,"_parent")不如使用parent.location.href=url;