想在点击子页面的某个链接时,显示父页面的某个部分,这个herf怎么写?

moonspider 2011-08-04 03:17:45
父页面index.htm有以下内容:
<a name="top" id="top"></a>



<div width="680">
<iframe src="outline.html" width="680" height="800" frameborder="0"name="event" id="event" style="overflow:hidden"></iframe>
</div>

子页面outline.html有以下内容:

<div ><a href="#top">返回页面最前端</a> ▲</div>

想在点击[子页面outline.html]的[返回页面最前端]时,显示父页面的[<a name="top" id="top"></a>]部分。

请问,[子页面outline.html]的这个herf怎么写?
...全文
176 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
moonspider 2011-08-04
  • 打赏
  • 举报
回复
谢谢楼上。我又试了,发现有时候可以,有时中断。可能别的东西影响。真的很感谢楼上
MuBeiBei 2011-08-04
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 moonspider 的回复:]
><a href="javascript:void(0)" onclick="javascript:parent.location = 'index.htm#top'">

这样使用后,结果抛错。
内容是主页面index.htm不能打开。操作中断
[/Quote]


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>The First Web Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<a name="top" id="top"></a>
<div width="680">
<iframe src="111111111.html" width="680" height="800" frameborder="0"name="event" id="event" style="overflow:hidden"></iframe>
</div>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<div ><a href="javascript:void(0)" onclick="javascript:parent.location = 'Untitled-7.html#top'">返回页面最前端</a> ▲</div>
</body>
</html>


我试了下~·没发现问题。。。
moonspider 2011-08-04
  • 打赏
  • 举报
回复
><a href="javascript:void(0)" onclick="javascript:parent.location = 'index.htm#top'">

这样使用后,结果抛错。
内容是主页面index.htm不能打开。操作中断
MuBeiBei 2011-08-04
  • 打赏
  • 举报
回复
<div ><a href="javascript:void(0)" onclick="javascript:parent.location = 'index.htm#top'">返回页面最前端</a> ▲</div>

这样~·
moonspider 2011-08-04
  • 打赏
  • 举报
回复
楼上大概理解错我的意思了。

我是想要点击[返回页面最前端]后回到父页面的最前端。而不是显示那个锚
moonspider 2011-08-04
  • 打赏
  • 举报
回复
<div ><a href="javascript:void(0)" onclick="javascript:parent.document.getElementById('top').style.display = 'block'">返回页面最前端</a> ▲</div>


这个方法试过了,不行啊。
MuBeiBei 2011-08-04
  • 打赏
  • 举报
回复
href="#top"这个改成javascript:void(0)
如果你页面上没有锚点的话~·


<div ><a href="javascript:void(0)" onclick="javascript:top.document.getElementById('top').style.display = 'block'">返回页面最前端</a> ▲</div>
MuBeiBei 2011-08-04
  • 打赏
  • 举报
回复
<div ><a href="#top" onclick="javascript:top.document.getElementById('top').style.display = 'block'">返回页面最前端</a> ▲</div>

87,989

社区成员

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

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