How open new window directly when loading TW?

79 views
Skip to first unread message

Mat

unread,
Apr 4, 2017, 3:29:03 PM4/4/17
to TiddlyWiki
I want an additional separate browser window to open when I surf to my TW, i.e the same result as when clicking the tiddler toolbar button "Open in new window".

The hope is to make my plugin TW Admin so that one can surf directly to http://.../#tw-admin and have the tiddler show in a separate window right away. The separate window should not open if that tiddler is not in the url. I guess it would be good if it always opens that tiddler as a separate window if it appears .

The ideal would be for this to be made in wikitext but I suspect that is not possible.

The "Open in new window" button relies on the tw-open-window message, which is defined in:

https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/startup/windows.js

...but I'm guessing it is some other mechanism that would trigger it on startup, perhaps

https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/startup/load-modules.js

Unfortunately, I have no idea what to do next.


Generally it would be cool if one could tag tiddlers to have them open separately on startup, but that is more than I need in my particular case where I only want a specific tiddler to open separately.

An alternative might be to add a what's-it-called to the url like so http://....:foo i.e a colon with some parameter that triggers something that is defined in the TW. I believe Tobias and Jed have experimented with such things.

So - any ideas how this can be made?

Thanks!

<:-)

Jeremy Ruston

unread,
Apr 4, 2017, 3:38:57 PM4/4/17
to tiddl...@googlegroups.com
Hi Mat

Not wishing to discourage you, but browsers have invested 20 years of effort into stopping web pages from being able to open popup windows without user interaction. I don’t think you’ll succeed without a browser extension of some sort.

(The current open-in-new-window code only works in modern browsers because it is executed directly in response to a user interaction; trying to open a new window with a timer won’t work on most browsers).

Best wishes

Jeremy.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4138e574-0e36-4954-92ad-7da8f9be292e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mat

unread,
Apr 4, 2017, 5:25:45 PM4/4/17
to TiddlyWiki
Ok, thanks for reply Jeremy.
I will have to manually click a button.... Life's brutal...
.😭

<:-)

Douglas Counts

unread,
Apr 5, 2017, 1:25:37 AM4/5/17
to TiddlyWiki
You can use `window.open()` to open a new window, control its appearance, turn off things like toolbars, or do just about anything else you would like to do.

The trick is to change the window in some way such as removing the status bar, setting a width, etc.  Those can't be opened in a tab, thus forcing the browser to override its default setting to open all new windows in a tab.

```
window.open('http://www.google.com', '_blank', 'toolbar=0,location=0,menubar=0');
```

-Doug

Douglas Counts

unread,
Apr 5, 2017, 2:08:26 AM4/5/17
to TiddlyWiki
Oh, I thought that I might add that is how those annoying "Your computer is infected" malware advertisements work where they pop up regardless of your browser's settings.

-Doug

Douglas Counts

unread,
Apr 5, 2017, 2:44:46 AM4/5/17
to TiddlyWiki
Looks like I was wrong as Chrome must track clicks somehow because when I placed the window.open() code inside a DOMContentLoaded event listener it didn't work.  Also when using setTimer() to click a link, chrome said "popup blocked", so that didn't work either.

Your manual mouse click must be required at some point to start the process of opening a window.  Chrome apparently does a good job of tracking all the JavaScript initiated from a click.

I can use setTimer() to open the window at a later time, but it has to be initiated from within code started from a mouse click.

-Doug

Mat

unread,
Apr 5, 2017, 4:54:49 AM4/5/17
to TiddlyWiki
Douglas, warm thanks for trying!

<:-)
Reply all
Reply to author
Forward
0 new messages