forked from ibebbs/ScriptVsNewWindow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenWindow.html
41 lines (37 loc) · 1.67 KB
/
OpenWindow.html
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
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript">
var openedWindow;
console.log(window['TESTDATA'])
function openWindow() {
openedWindow = window.open('https://ian.bebbs.co.uk')
console.log('window opened')
console.log(openedWindow['TESTDATA'])
}
function openNewWithJSOnly() {
let newWindow = window.open('about:blank');
newWindow.console.log('!!! document is being updated by parent window !!!')
let button = newWindow.document.createElement('button');
button.id = 'new-tab-button'
button.onclick = function () { window.open('https://ian.bebbs.co.uk'); };
button.textContent = "Open Tab1"
newWindow.document.body.appendChild(button);
let div = newWindow.document.createElement('div');
div.id = 'new-tab-div'
div.innerText = 'This content is generated purely by javascript';
newWindow.document.body.appendChild(div);
newWindow.document.title = 'Title set by javascript';
newWindow.console.log('!!! document has been updated by parent window !!!')
}
</script>
</head>
<body>
<h1>hello world</h1>
<p><button onclick="openWindow()">Open Window From Javascript (GET)</button></p>
<p><button onclick="openNewWithJSOnly()">Open Window From Javascript without navigation</button></p>
<p><a target="_blank" href="https://ian.bebbs.co.uk">Open Window From Target="_blank" (GET)</a></p>
<p><a target="_blank" href="https://random.test.url/">Start open window test with POST navigation</a></p>
</body>
</html>