I know that in Javascript, I can call the function self.close() to close my current window.
I was wondering what if rather than closing the window I wanted to alert “foo”, is that possible?
which in this case my code would look like
function funky(){
alert("foo");
}
can I do this in my html
self.funky()
To invoke funky? In other words I want to alert my user a message before they close the browser
The global property “self” is just an alias for
window(in some browsers). Thus any property ofwindowcan be accessed via “self” too.If you declare a global function, then it too becomes a property of “self”/
window.