On Wednesday, August 12, 2020 at 8:59:53 PM UTC-7, TonyM wrote:
>
> The close function is documented here, and the windows opened need a name,
> https://developer.mozilla.org/en-US/docs/Web/API/Window/close
>
On that page, it says this about closing the current window:
Closing the current window
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)
function closeCurrentWindow() {
window.close();}
Thus, it is not possible to *programmatically* close the current window
from javascript. You can only close a window from it's parent, and then
only if you have the window's handle (returned when the window.open(...)
was called)
However... it turns out there *is* a way to close the current window... but
only from a user-initiated click interaction:
<a href="javascript:window.close()"> close this window </a>
Thus, you can do the following using a TiddlyWiki $button widget
<$button>
<a href="javascript:window.close()"> {{$:/core/images/close-button}} </a>
</$button>
Note that the click action has to be on the actual *content* (in this
example, the close-button image), so clicking near the edge of the button,
but not on the content itself, does nothing.
-e
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/ccdfa0a7-808a-4afb-90c2-6857239dea9do%40googlegroups.com.