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

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

问题描述

我知道_blank在与锚标记一起使用时会打开一个新选项卡,并且在使用框架集时还有自定义的目标,但我想知道_parent,_self和_top

$之间的区别。恕我直言,我不认为他们完全解决了这个问题。这些答案很好,恕我直言,我不认为他们完全解决了这个问题。

锚点属性中的目标标记告诉浏览器锚点目的地的目标。它们最初是为了操纵和指引锚文档的框架系统而创建的。



虽然 target =_ self是默认的浏览器,最常见的目标是 target =_ blank,它会在新窗口中打开锚(通常通过浏览器设置将其重定向到标签)。 _ parent_ top framename 标记对于那些不熟悉iframe网站建设日趋成为趋势的人来说,这是一个谜。

target =_ self这会在同一个框架中打开一个锚点。令人困惑的是,因为我们通常不再写入框架(并且 frame frameset 标签已过时在HTML5中)人们假设这是一个相同的窗口函数。相反,如果此锚点嵌套在框架中,它将以沙箱模式打开,仅在该框架中显示。



target =_ parent 如果它们嵌套在另一个框架中,将在下一层级中打开



target = _top它在嵌套的所有框架之外突破并在浏览器窗口中打开链接作为顶层文档。

target =framename 这是最初被弃用的,但被带回到HTML5中。 。 name 是使用 id 识别标记取代方法的正确方法。

 <! - 示例: - > 

< html>
< head> ;
< / head>
< body>
< iframe src =url1name =A>< p>这是我的第一个iframe< / p><< ; / iframe>
< iframe src =url2name =B>< p>这是我的第二个iframe< / p>< / iframe>
< iframe src = url3name =C>< p>这是我的第三个iframe< / p>< / iframe>

< a href =url4target =B><< ; / a>
< / body>
< / html>


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.

The target tag in an anchor attribute 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.

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" 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" Will open the in the next level up of a frame if they were nested to inside one another

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 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天全站免登陆