w3c validation for target blank
target=_blank
is perfectly valid HTML5. Try the below HTML document in the W3 Validator
<!doctype html>
<head><title>blank</title></head>
<body><p>A link to <a href="http://example.com" target="_blank">Example</a>...</body>
XHTML Strict 1.0 - target=_blank not valid?
You might want to check out the W3 Frequently Asked Questions: http://www.w3.org/MarkUp/2004/xhtml-faq#target
Why was the target attribute removed from XHTML 1.1?
It wasn't. XHTML 1.0 comes in three versions: strict, transitional, and frameset. All three of these were deliberately kept as close as possible to HTML 4.01 as XML would allow. XHTML 1.1 is an updated version of XHTML 1.0 strict, and no version of HTML strict has ever included the target attribute. The other two versions, transitional and frameset, were not updated, because there was nothing to update. If you want to use the target attribute, use XHTML 1.0 transitional.
How do I add target=_blank to a link within a specified div?
/* here are two different ways to do this */
//using jquery:
$(document).ready(function(){
$('#link_other a').attr('target', '_blank');
});
// not using jquery
window.onload = function(){
var anchors = document.getElementById('link_other').getElementsByTagName('a');
for (var i=0; i<anchors.length; i++){
anchors[i].setAttribute('target', '_blank');
}
}
// jquery is prettier. :-)
You could also add a title tag to notify the user that you are doing this, to warn them, because as has been pointed out, it's not what users expect:
$('#link_other a').attr('target', '_blank').attr('title','This link will open in a new window.');
Is it alright to use target=_blank in HTML5?
It looks like target="_blank"
is still alright. It is listed as a browsing context keyword in the latest HTML5 draft.
How to simulate target=_blank in JavaScript
<script>
window.open('http://www.example.com?ReportID=1', '_blank');
</script>
The second parameter is optional and is the name of the target window.
jQuery add target=_blank for outgoing link
assuming that all external links will start with http:// you could do this:
$('a[href^="http://"]').not('a[href*=gusdecool]').attr('target','_blank');
How to add target=_blank to JavaScript window.location?
window.location
sets the URL of your current window. To open a new window, you need to use window.open
. This should work:
function ToKey(){
var key = document.tokey.key.value.toLowerCase();
if (key == "smk") {
window.open('http://www.smkproduction.eu5.org', '_blank');
} else {
alert("Kodi nuk është valid!");
}
}
What is the difference between target=_blank and target=blank?
blank
targets an existing frame or window called "blank". A new window is created only if "blank" doesn't already exist.
_blank
is a reserved name which targets a new, unnamed window.
Related Topics
Placeholder Attribute on Input Tags for Ie
Single Versus Double Quotation Marks in HTML & CSS
What Tag Should I Use Instead of Deprecated Tag Font in HTML (Cannot Use CSS)
Zooming on a Point with CSS3 Transform Scale
Position Sticky Not Working with Body{ Overflow-X: Hidden; }
Creating a Triangle in CSS with a Gradient Background
Enable Support for CSS3 ::Outside Pseudoelement
Bootstrap 3 CSS Image Caption Overlay
How to Center an Image That Is Wider Than the Browser Window (Not a Background Image)
Moodle Not Showing CSS and Theme with Linux Server
Can You Reference Images from CSS Without Using Relative Paths
Css3 Scale() Causes Divs to Become Pixelated
Appbar Overlaps with Other Elements