user1950278
user1950278

Reputation: 1883

JS window.close doesnt work

Code snippet to make make popup window:

<script>
function about() {
window.open( "/aboutserver.html", "_blank", 
"location=no, titlebar=no, status = no, height = 650, width = 300, resizable = no, location=no, menubar=no, scrollbars=no, toolbar=no");
}
</script>
<a href="#" onClick="about()">Server Info</a> <br>

Here is the code of the actual popup window:

<div align="center"><html><body><h1>Info</h1></div>
<br>Provides:<br><br><br>
blah blah etc
<script>
function close(){
window.self.close();
}
</script>
<button onClick=close()>Close</button>

I have also tried window.close(); and window.close('aboutserver.html')

Upvotes: 0

Views: 348

Answers (1)

Ruan Mendes
Ruan Mendes

Reputation: 92274

You're overriding the global close function. You should be getting a stack overflow error from the function trying to call itself.

You can just remove your custom close function and just call the global close() directly, or rename your function to something like closeWin

Upvotes: 1

Related Questions