1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<!DOCTYPE html>
<!-- target: hello.txt -->
<!--
Some pages (*cough* Reddit *cough*) insert a target=_blank *after* a link was
clicked, which is early enough for the browser to try and open a new tab, but
too late for hints to notice. This means the page won't be opened at all when
javascript-can-open-windows is false.
-->
<html>
<head>
<meta charset="utf-8">
<title>Link where we insert target=_blank via JS</title>
<script type="text/javascript">
function setup_event_listener() {
var elem = document.getElementById('link');
elem.addEventListener('click', function() {
elem.target = '_blank';
});
}
</script>
</head>
<body onload="setup_event_listener()">
<a href="/data/hello.txt" id="link">Follow me!</a>
</body>
</html>
|