锚标签目标属性中_self、_top、_parent的区别 [英] Difference between _self, _top, and _parent in the anchor tag target attribute

查看:12
本文介绍了锚标签目标属性中_self、_top、_parent的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 _blank 在与锚标记一起使用时会打开一个新选项卡,而且我在使用框架集时使用了自定义目标,但我想知道 _parent 之间的区别_self_top.

I know _blank opens a new tab when used with the anchor tag and also, there are self-defined targets I use when using framesets but I will like to know the difference between _parent, _self and _top.

推荐答案

虽然这些答案很好,但恕我直言,我认为它们并没有完全解决问题.

While these answers are good, IMHO I don't think they fully address the question.

锚标记中的目标属性告诉浏览器锚的目的地的目标.它们最初的创建是为了操纵和引导锚点到文档的框架系统.这是在 CSS 帮助 HTML 开发人员之前很久.

The target attribute in an anchor tag tells the browser the target of the destination of the anchor. They were initially created in order to manipulate and direct anchors to the frame system of document. This was well before CSS came to the aid of HTML developers.

虽然 target="_self" 是浏览器的默认设置,最常见的目标是 target="_blank" 它在新窗口中打开锚点(已被通常通过浏览器设置重定向到选项卡)."_parent""_top"framename 标签对于那些不熟悉 iframe 网站建设时代的人来说是一个谜作为趋势.

While target="_self" is default by browser and the most common target is target="_blank" which opens the anchor in a new window(which has been redirected to tabs by browser settings usually). The "_parent", "_top" and framename tags are left a mystery to those that aren't familiar with the days of iframe site building as the trend.

target="_self" 这会在同一帧中打开一个锚点.令人困惑的是,因为我们通常不再编写框架(并且 frameframeset 标签在 HTML5 中已经过时)人们认为这是一个相同的窗口函数.相反,如果此锚点嵌套在框架中,它将以某种沙盒模式打开,这意味着仅在该框架中.

target="_self" This opens an anchor in the same frame. What is confusing is that because we generally don't write in frames anymore (and the frame and frameset tags are obsolete in HTML5) people assume this a same window function. Instead if this anchor was nested in frames it would open in a sandbox mode of sorts, meaning only in that frame.

target="_parent" 如果它们相互嵌套,将在框架的下一级打开它们

target="_parent" Will open the in the next level up of a frame if they were nested to inside one another

target="_top" 这会在它嵌套的所有框架之外中断,并在浏览器窗口中将链接作为顶部文档打开.

target="_top" This breaks outside of all the frames it is nested in and opens the link as top document in the browser window.

target="framename 这最初已被弃用,但在 HTML5 中恢复.这将针对有问题的确切框架.虽然 name 是该方法具有的正确方法被替换为使用 id 标识标签.

target="framename This was originally deprecated but brought back in HTML5. This will target the exact frame in question. While the name was the proper method that method has been replaced with using the id identifying tag.

<!--Example:-->

<html>
<head>
</head>
<body>
<iframe src="url1" name="A"><p> This my first iframe</p></iframe>
<iframe src="url2" name="B"><p> This my second iframe</p></iframe>
<iframe src="url3" name="C"><p> This my third iframe</p></iframe>

<a href="url4" target="B"></a>
</body>
</html>

这篇关于锚标签目标属性中_self、_top、_parent的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆