Solution Want exit button to close browser

In the post https://www.sitepoint.com/community/t/php5-want-exit-button-to-close-browser/6911,
i couldn’t reply, but i have an answer to the last reply in this post.
The way to open window with javascript.
This is a code example.

<a type="button" class="btn btn-danger btn-sm" 
href="here put the link, could be a php ref with parameters" 
target="_blank" 
onClick="window.open(this.href, this.target, 'width=500px,height=500px'); return false;">
Button Name</a>

Href example with parameters:
archivo.php?accion=files&nmtbl=../data/files/filepru.txt&n=0&txt=First Line.
To styling the button ,i use bootstrap. But is not a restricted, or the only way, there are many ways, use the better for you.

That post is 9 years old @luisga158 and is about how to close a browser window. You’re explaining how to open a browser window. I’m not sure this is an answer to the actual question…

I think I see. In that topic, it was established that for script to be able to close a window, that window needed to be opened by script. It is intuitive that having code that opens a window would therefore be a requirement.

What I think has been missed is that window.open is a method of the Window object and that window.open opens a new window object.

The browser belongs to the user, not a website, so the interfaces are relatively restrictive. eg.

  • page A script opens a new object containing page B
  • page A script can close that same object containing page B

.

In the past, when you called the window object’s close() method directly, rather than calling close() on a window instance , the browser closed the frontmost window, whether your script created that window or not. This is no longer the case; for security reasons, scripts are no longer allowed to close windows they didn’t open. (Firefox 46.0.1: scripts can not close windows, they had not opened)

1 Like