如何指向 xx frameset 的 src ?

潇洒 2002-09-12 12:33:34
问题: 现有一框架页面如下.

<frameset rows="80,*" cols="*" frameborder="yes" border="1" framespacing="1">
<frame src="top.php" name="topFrame" scrolling="NO" >
<frameset rows="*" cols="156,*" framespacing="1" frameborder="yes" border="1">
<frame src="customer_menu.php" name="leftFrame" scrolling="auto">
<frame src="about:blank" name="mainFrame">
</frameset>
</frameset>

请问, 如何在 customer_menu.php 里指向 mainFrame 的 src ?
注: 不是用 <a href=> 的 target 属性, 这样可以访问. 但现在需要的是
在 <table> 表格里 onclick 然后再改变mainFrame的 src.

我现在用 onclick="mainFrame.src='url'" .... 却显示说"找不到对象."
我用 onclick="parent.mainFrame.src='url'" 虽不提示出错, 但还是无法
实现所需的效果(将地址指向mainFrame 的 src).

各位老大, 我是没辙了. 以前比较少搞 frame 的页面. 所以.......


================================================================
俺是"老"菜鸟一只, 请各位高手多指教!
------ 好好学习, 天天上网! --------
→→→→→→→→→→→→→→→→→→↓
↑ 哎.. 现在上 google 越来越困难了. ↓→→→→→→→→→→→→
↑ 刚写了个简单的script,大家看看能不能找到可用的 google IP. ↓
↑ http://www.yaoba.com/~goldenlove/google_all.htm↓←←←←↓
←←←←←←←←←←←←←←←←←←←←←←←←←↓
多谢 CSDN 助手帮我自动加入签名.
www.chinaok.net
================================================================
...全文
128 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
潇洒 2002-09-12
  • 打赏
  • 举报
回复
function getUrl(url){
top.frames('mainFrame').location.href=url;
}

<tr valign="top" onclick="getUrl('customer_view.php?number=$number');">

老大, !! 我这样写有错么!? 怎么还是不行啊? 应该是照您的方法做了哦!?

它没提示别的就说俺这句 top.frames('mainFrame').location.href=url;
有错, 错误提示"发生以外" ! 我晕. 怎么回事?
qiushuiwuhen 2002-09-12
  • 打赏
  • 举报
回复
<frameset rows="80,*" cols="*" frameborder="yes" border="1" framespacing="1">
<frame src="about:top.php" name="topFrame" scrolling="NO" >
<frameset rows="*" cols="156,*" framespacing="1" frameborder="yes" border="1">
<frame src="about:<table border><td onclick=top.mainFrame.location.href='about:hehe'>customer_menu.php</table>" name="leftFrame" scrolling="auto">
<frame src="about:blank" name="mainFrame">
</frameset>
</frameset>
qiushuiwuhen 2002-09-12
  • 打赏
  • 举报
回复
<frameset rows="80,*" cols="*" frameborder="yes" border="1" framespacing="1">
<frame src="about:top.php" name="topFrame" scrolling="NO" >
<frameset rows="*" cols="156,*" framespacing="1" frameborder="yes" border="1">
<frame src="about:<table border><td onclick=top.frames('mainFrame').location.href='about:hehe'>customer_menu.php</table>" name="leftFrame" scrolling="auto">
<frame src="about:blank" name="mainFrame">
</frameset>
</frameset>
yonghengdizhen 2002-09-12
  • 打赏
  • 举报
回复

parent是window的属性呀..
这里默认的名字空间是window.
所以将window.parent简写为parent
潇洒 2002-09-12
  • 打赏
  • 举报
回复
呵呵~~ 问题已经解决. 真是晕..

直接这样 parent.mainFrame.location=url; 就可以了.
可我刚开始怎么试都不行.

再次感谢各位的帮助. 结帖. 给分!
潇洒 2002-09-12
  • 打赏
  • 举报
回复
1. 你的代码运行过了, 的确可以. 很正常.
(但我用相同的代码只加了个function 就不行?)

2. 经过几次核查. customer_menu.php 和 frame 页内都无name=top
和 name= parent 的控件.
-----------------------------------------------------------------
<frameset rows="50,*" cols="*" frameborder="yes" border="1" framespacing="1">
<frame src="top.php" name="topFrame" scrolling="NO" >
<frameset rows="*" cols="156,*" framespacing="1" frameborder="yes" border="1">
<frame src="customer_menu.php" name="leftFrame" scrolling="auto">
<frame src="<? echo "customer_view.php?number=$number"; ?>" name="mainFrame">
</frameset>
</frameset>
-----------------------------------------------------------------
qiushuiwuhen 2002-09-12
  • 打赏
  • 举报
回复
1.执行我的代码看看行不行

2.看自己的代码中是否有name=top的控件

这里top和parent没什么区别
yonghengdizhen 2002-09-12
  • 打赏
  • 举报
回复
当然有错
function getUrl(url){
parent.frames('mainFrame').location.href=url;
}

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧