Last active
August 29, 2015 14:27
-
-
Save programus/197e699e4024c6536005 to your computer and use it in GitHub Desktop.
close popup after changed html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja-JP"> | |
<head> | |
<title>From</title> | |
<meta charset="UTF-8"> | |
</head> | |
<body onload="document.getElementById('closed-flg').checked = true;"> | |
<input type="checkbox" id="closed-flg"/> | |
<a href="#" onclick="window.open('popup.html', 'popup'); document.getElementById('closed-flg').checked = false; ">popup</a> | |
<a href="#" id="link-to" onclick="window.location.href='to.html' + (document.getElementById('closed-flg') ? '' : '?popup');">To</a> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja-JP"> | |
<head> | |
<title>Pop Up</title> | |
<meta charset="UTF-8" /> | |
<script> | |
var notifyClose = function() { | |
window.opener.document.getElementById('closed-flg').checked = true; | |
}; | |
window.onbeforeunload = notifyClose; | |
</script> | |
</head> | |
<body onunload="notifyClose();" > | |
Popup Page | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja-JP"> | |
<head> | |
<title>To</title> | |
<meta charset="UTF-8" /> | |
<script> | |
var closeWindow = function () { | |
var s = window.location.href.split('?'); | |
if (s.length > 1) { | |
if (!document.getElementById('closed-flg').checked) { | |
popup = window.open('', 'popup'); | |
popup.close(); | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<input type="checkbox" id="closed-flg"/> | |
<a href="#" onclick="closeWindow();">Close Popup</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment