File: simple_links.html

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (87 lines) | stat: -rw-r--r-- 3,544 bytes parent folder | download | duplicates (7)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<html>

 <head><title>Simple links</title>
 <script>
  function simulateClick(target) {
    var evt = document.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
                       0, 0, 0, 0, 0, false, false,
                       false, false, 0, null);

    return target.dispatchEvent(evt);
  }

  function setPortNumber(portNumber) {
    var link = document.getElementById("cross_site_link");
    link.setAttribute("href", "http://foo.com:" + portNumber + "/title2.html");

    link = document.getElementById("cross_site_new_window_link");
    link.setAttribute("href", "http://foo.com:" + portNumber + "/title2.html");

    link = document.getElementById("cross_site_new_window_no_opener_link");
    link.setAttribute("href", "http://foo.com:" + portNumber + "/title2.html");
    return true;
  }

  function clickSameSiteLink() {
    return simulateClick(document.getElementById("same_site_link"));
  }

  function clickSameSiteNewWindowLink() {
    return simulateClick(document.getElementById("same_site_new_window_link"));
  }

  function clickSameSiteNewWindowWithNoopenerLink() {
    return simulateClick(document.getElementById("same_site_new_window_with_noopener_link"));
  }

  function clickSameSiteNewWindowWithOpenerLink() {
    return simulateClick(document.getElementById("same_site_new_window_with_opener_link"));
  }

  function clickCrossSiteLink() {
    return simulateClick(document.getElementById("cross_site_link"));
  }

  function clickCrossSiteNewWindowLink() {
    return simulateClick(document.getElementById("cross_site_new_window_link"));
  }

  function clickCrossSiteNewWindowNoOpenerLink() {
    return simulateClick(document.getElementById("cross_site_new_window_no_opener_link"));
  }

  function clickViewSourceLink() {
    return simulateClick(document.getElementById("view_source_link"));
  }

  function clickLinkToSelf() {
    return simulateClick(document.getElementById("link_to_self_opener"));
  }

  function clickLinkToSelfNoOpener() {
    return simulateClick(document.getElementById("link_to_self_no_opener"));
  }

  function clickGoogleChromeLink() {
    return simulateClick(document.getElementById("google_chrome_link"));
  }
 </script>
 </head>

<a href="title2.html" id="same_site_link">same-site</a><br>
<a href="http://foo.com/title2.html" id="cross_site_link">cross-site</a><br>
<a href="view-source:about:blank" id="view_source_link">view-source:</a><br>
<a href="title2.html" id="same_site_new_window_link" target="_blank">same-site new window</a>
<a href="title2.html" id="same_site_new_window_with_noopener_link" rel="noopener" target="_blank">same-site new window with noopener</a>
<a href="title2.html" id="same_site_new_window_with_opener_link" rel="opener" target="_blank">same-site new window with opener</a>
<a href="http://foo.com/title2.html" id="cross_site_new_window_link" rel="opener" target="_blank">cross-site new window</a>
<a href="http://foo.com/title2.html" id="cross_site_new_window_no_opener_link" rel="noopener" target="_blank">cross-site new window no opener</a>
<a href="" id="link_to_self_opener" rel="opener" target="_blank">self new window_opener</a>
<a href="" id="link_to_self_no_opener" rel="noopener" target="_blank">self new window_noopener</a>
<script>
  document.getElementById("link_to_self_opener").href = window.location.toString();
  document.getElementById("link_to_self_no_opener").href = window.location.toString();
</script>
<a href="googlechrome://" id="google_chrome_link">googlechrome:</a></br>
</html>