Reputation: 79
I'm trying to close another window when I'm clicking on a specific link. (with javascript)
I have only find a solution where I can close the current window I'm in.
I'm in shop.php and want to close client.php
So when I'm click on the shop.php I will close client.php..
<li class="viptab"><a href="{url}/shop" target="_blank" onClick="javascript:window.close('client.php')">SHOP</a><span></span></li>
Any suggestions?
Upvotes: 2
Views: 1464
Reputation: 79
Use if you want close current window .
<button onclick="self.close()">Close </button>
Or use this if you want close child window from parent
<!DOCTYPE html>
<html>
<body>
<button onclick="openWin()">Open </button>
<button onclick="closeWin()">Close </button>
<script>
var myWindow;
function openWin() {
myWindow = window.open("/client.php", "_blank", "width=500, height=500");
}
function closeWin() {
myWindow.close();
}
</script>
</body>
</html>
Upvotes: 3