Hello all i need to find away to stop/terminate apache web server that is running on my local pc when i close the site that is running in my local pc (for example http://localhost:8080) or when i close the browser that display/load the localhost site that the local apache web server is running . what is the preferred way ?
views:
92answers:
2
+1
A:
I don't think this can be done. There's no connection between a browser and the web server after the site's elements have been downloaded, so there's no way for the web server to know whether some browser is still displaying the page. In my opinion what you want to do just can't be done.
Thorsten Dittmar
2009-11-04 15:52:44
im sure there is somekind of trick or work around for this but the question is what
2009-11-05 05:15:15
No - I'm quite sure there's not.
Thorsten Dittmar
2009-11-05 08:25:11
A:
there's javascript "onbeforeunload" ... you could have a cgi script running as root terminate apache when the "onbeforeunload" triggers it via ajax.
but that's only really doable if you're the only one visiting that page - otherwise anyones closed window would be the end of apache.
lixlpixel
2009-11-05 15:15:26
Will OnBeforeUnload be called when he closes the window? It won't work reliably when I disable JavaScript in my browser and visit his site...
Thorsten Dittmar
2009-11-05 16:07:32