+ 2
What is the difference between _top and _parent target attribute in HTML
it seems to be same but how are they different
3 odpowiedzi
+ 12
They are mostly used with iframes.
For example, you have three web pages:
iframe1.html
iframe2.html
iframe3.html
Then imagine two things:
- iframe2 contains iframe1
- iframe3 contains iframe 2
When you open iframe3.html you are going to see 3 boxes, the biggest one is the whole page that's iframe3, inside of it there are 2 other boxes, one is for iframe2.html and the other one inside iframe2 you are going to see iframe1.
(It's like Inception or The Matrix haha one reality inside another reality and so on 😊)
Anyways, let's say iframe1 has 2 links in its HTML body:
<a href="url" target="_top"> Top </a>
If you click on this text link: Top, it is going to open on the whole page because the iframe at the "top" of all (or that contains them all) is iframe3.
<a href="url" target="_parent"> Parent </a>
If you click on the link: Parent, it will open on iframe2 only, because the "parent" of iframe 1 is iframe2.
I hope I was able to explain it well 😊
+ 6
_parent opens a new page in the parent frame (level relative -1)
_top opens in a fullpage (level absolute 0)
+ 2
thanks for your help