1

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?

2
  • Did JavaScript open up the window? AKA window.open() Sep 5, 2014 at 13:20
  • Yes, it did. Opened shop and client at the same time. Sep 5, 2014 at 13:24

1 Answer 1

2

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>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.