window.location.href解决target问题

本文介绍了HTML中使用框架进行页面布局的方法,并详细解析了如何通过脚本控制框架内的页面跳转,包括从子框架触发父框架内指定区域的内容更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

3个页面

1 index.html

Html代码 复制代码 收藏代码
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  5. <title>无标题文档</title>
  6. </head>
  7. <frameset rows="*" cols="241,*" framespacing="0" frameborder="NO" border="0">
  8. <frame src="UntitledFrame-2.htm" id="leftFrame" name="leftFrame" scrolling="NO" noresize>
  9. <frame src="Untitled-1.htm" id="rigthmain" name="rigthmain">
  10. </frameset>
  11. <noframes><body>
  12. </body></noframes>
  13. </html>

2 Untitled-1.htm

Html代码 复制代码 收藏代码
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  6. <title>无标题文档</title>
  7. </head>
  8. <body>
  9. dasssssssssssssssssssssss
  10. </body>
  11. </html>

3 UntitledFrame-2.htm

Html代码 复制代码 收藏代码
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  6. <title>无标题文档</title>
  7. </head>
  8. <script>
  9. function aa(){
  10. window.parent.rigthmain.location.href="http://www.baidu.com";
  11. }
  12. </script>
  13. <body>
  14. <a onClick=" aa()">a</a>
  15. </body>
  16. </html>

重点解析

window.parent.rigthmain.location.href="http://www.baidu.com";
parent取父框架

rigthmain去子框架

=========================================================================================

此外,我一直用的

<input align="right" type="button"  name="add" onclick="window.location.href('addCard.jsp')" value="+ 新增"/>
在按钮所在页面打开addCard.jsp页面,而:
<input align="right" type="button"  name="add" onclick="window.parent.rigthmain.location.href('addCard.jsp')" value="+ 新增"/>

是在按钮所在框架的父框架的子框架(即rightmain)打开addCard.jsp页面。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值