File: target_blank_js.html

package info (click to toggle)
qutebrowser 3.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,432 kB
  • sloc: python: 72,411; javascript: 31,862; sh: 874; xml: 149; makefile: 52
file content (28 lines) | stat: -rw-r--r-- 865 bytes parent folder | download | duplicates (4)
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>