I have code something like this:
<a href="http://google.com" target="_blank">google</a>
<a href="http://gmail.com" target="_blank">gmail</a>
Whenever I click one of the links, a new window or tab is created. I wanted the links to just use one.
So I changed my code like this:
<a href="http://google.com" target="google">google</a>
<a href="http://gmail.com" target="google">gmail</a>
It worked! It makes a new window just the first time either link is clicked, and after that clicks on the links appear in that window.
I think this is good, but I cannot find something about this in the W3C HTML 4 Spec. Is it valid and cross-browser compatible?
Definition and Usage The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form. The target attribute defines a name of, or keyword for, a browsing context (e.g. tab, window, or inline frame).
_blank: It opens the link in a new window. _self: It is the default value. It opens the linked document in the same frame. _parent: It opens the linked document in the parent frameset.
The <a> nchor element is simply an anchor to or from some content. Originally the HTML specification allowed for named anchors ( <a name="foo"> ) and linked anchors ( <a href="#foo"> ).
Yes, that's exactly how you would use it in this instance. The value of the target
attribute specifies where to open the linked document and can be one of _blank
, _self
, _parent
, _top
, or framename
, where framename would be the name of the frame or window to use.
Yes, that is perfectly valid and browser-compatible. The target
specifies the name of the target window (or frame), which will be opened when it does not already exist.
The following have special meanings: _self
, _blank
, _parent
, _top
Maybe you need a better HTML reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With