-
Notifications
You must be signed in to change notification settings - Fork 0
/
openwindow_iframe.js
28 lines (24 loc) · 1.12 KB
/
openwindow_iframe.js
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
document.querySelectorAll('.opener').forEach((btn => {
btn.addEventListener('click', (evt) => {
const targetId = `${evt.target.dataset.target}`;
window.popupWindow = window.open('openwindow_iframe.html', targetId);
window.popupWindow.postMessage("aaaaaaaaaaaaaaaaaaaaaaaaaaa", location.origin);
});
}));
document.querySelectorAll('.noopener').forEach((btn => {
btn.addEventListener('click', (evt) => {
const targetId = `${evt.target.dataset.target}`;
window.popupWindow = window.open('openwindow_iframe.html', targetId, 'noopener');
window.popupWindow.postMessage("aaaaaaaaaaaaaaaaaaaaaaaaaaa", location.origin);
});
}));
document.querySelectorAll('.noreferrer').forEach((btn => {
btn.addEventListener('click', (evt) => {
const targetId = `${evt.target.dataset.target}`;
window.popupWindow = window.open('openwindow_iframe.html', targetId, 'noreferrer');
window.popupWindow.postMessage("aaaaaaaaaaaaaaaaaaaaaaaaaaa", location.origin);
});
}));
window.addEventListener('message', (event) => {
console.log(`Received message: ${event.data}`);
});