Closing the browser tab

I’d like to close the tab where my web application is running at the Session.Close event.
Is it possible or is it forbidden by the browser?
Thanks for any hint.

Executejavascript(“window.close();”)

Perhaps?

[quote=418386:@Derk Jochems]Executejavascript(“window.close();”)

Perhaps?[/quote]
That’s what I tried but with no success.
In a Internet forum I found:

Re: How to close current tab with javascript Jul 24, 2018 02:19 PM|LINK current browser security only allows javascript to close a window that javascript opened.
I have no security that this is true but it could.
Thanks anyway.

I’d sure love to be able to do this as well, but I think I’ve heard on this forum that browser’s don’t allow this.

Found this for you:

https://www.computerhope.com/issues/ch000178.htm

Basicly you put this in a webpagesource:

function windowClose() {
window.open('','_parent','');
window.close();
}

And call executejavascript(“windowClose();”)

Untested but it should work

Thank you Derk.
Unfortunately I’ve never used WebPageSource and the help about it is practically useless.
I don’t know where to insert this function.

Finally I found where to insert the function.
Now I will try it.
However in "https://www.computerhope.com/issues/ch000178.htm " we can read:

[quote]As of 2017, there is no way to close a web browser tab or window using JavaScript. Modern security standards do not permit this behavior.
For historical reasons, this page lists methods that were formerly used to programmatically close a browser tab or window using JavaScript.[/quote]

[quote=418419:@Ramon SASTRE]Thank you Derk.
Unfortunately I’ve never used WebPageSource and the help about it is practically useless.
I don’t know where to insert this function.[/quote]

Ok then in app you see a property htmlheader
Add the code above within

That should work also (can only be done in the ide)

http://documentation.xojo.com/api/web/webapplication.html#webapplication-htmlheader

Thanks Derk,

At least I have learned how to use WebPageSource and how to include JavaScript functions in my applications.