how browsing-context works (browsing context)

Asked

Viewed 99 times

2

I was reading the attribute documentation target of the HTML element <a>:

(...) In HTML5, it is a name or keyword that refers to a browsing context (for example tab, window or frame) (...)

What is a browsing context and how it works?

1 answer

3


The browsing context can be understood as an instance (or session) of the browser, it can be a window, a tab or a <iframe>, with independent browsing history.

In HTML 5 a context is created when defining a <iframe> with the attribute name or click on a link or send a form with the attribute target defined other than special values (_self, _blank, etc..).

Working example:

Note: you need to save the content to an HTML file because it doesn’t work properly directly on the site due to restrictions.

Click the first link, it will open in a new tab (created a new context), go back to the tab and click the second link that will open in the same tab of the first link. Because both links have the attribute target worthwhile meu-contexto.

<ol>
  <li><a href="/" target="meu-contexto">StackOverflow pt</a></li>
  <li><a href="http://stackoverflow.com/" target="meu-contexto">StackOverflow en</a></li>
</ol>

The name of the current context can be accessed by the Javascript property window.name. Modifying this property can unlink the current context from the parent context. It is possible to create a link by modifying this property only when a parent/child relationship, as is the case with <iframe>.

Related documentation: http://www.w3.org/TR/2009/WD-html5-20090423/browsers.html#browsing-context

Browser other questions tagged

You are not signed in. Login or sign up in order to post.