Hi. I would appreciate hearing your opinion on this. I like Franz for it's simple design but sometimes I have to restart Franz to reset services when they loaded external links in the same window and I want to go back to their "serviceURL".
So, I'm now studying to fix this issue by making index.js scan for external links and preventing Franz to load them. Is it suitable for recipes to do such pre-process?
Always open external links in a new window
For recipe-side, avoid loading such links in Franz as follows :
module.exports = Franz => class SomeService extends Franz {
events = {
'dom-ready': '_scanForExternalLinks',
}
_scanForExternalLinks(event) {
[].forEach.call(document.querySelectorAll("a"),
e => {
if (e.host !== window.location.host)
e.setAttribute("onclick", "window.open(this.href); return false;");
})
}
};
Or, for client-side, I think there are some options :
Related: when I open links from gmail they open a new chrome window, but don't load the URL
For me it's not only Gmail, but all the other applications (Telegram, Whatsapp ..) as well. As soon as I click on a link, a new chrome window will be opened, but it does not load the URL.
I may have found a cause of the new browser window problem.
When I was debugging my Teamwork Projects recipe, I noticed a strange behavior of a print button located at gantt chart page. This button usually opens a new window showing a "Generating printable document..." message untll printing data is ready, then opens a print dialog of system when I use Teamwork Projects with other browsers.
But with Franz, it just opens a blank window and I cannot proceed to print out dialog. Teamwork Projects opens a new window by calling window.open() function as follows:
this.printWindow = window.open("", "", "width=" + window.innerWidth + ",height=" + window.innerHeight),
this.printWindow.document.write('<html><body style="margin: 0;">Generating printable document…</body></html>'),
this.printWindow.document.close(),
But when the window.open() function is called inside a WebView, it just returns a BrowserWindowProxy object to this.printWindow variable. And invoking this.printWindow.document.write() will fail because BrowserWindowProxy provides limited functionality and this.printWindow.document object is undefined.
Fortunately, electron provides also Chrome's built-in window.open() implementation as described here, so regarding the recipe of Teamwork Projects it fixes the problems by adding a property of webpreferences="nativeWindowOpen=yes" to the WebView tag defined at /src/components/services/content/ServiceWebview.js
Hope other services like Gmail, Telegram and Whatsapp will also be fixed by this solution.
@koma-private As you've written correctly in your PR this has the side effect open opening every link with a target="_blank" in Franz and in the browser. Unfortunately I don't have a solution yet.
@eddowding @batmel the issue you are describing is a chrome issue. You need to restart chrome. More infos can be found here: #264
possible Duplicate of #264
@BrianGilbert's workaround: right-click and select "Open Link"
@haraldox
Although I think I should change the title of this issue, I’m talking about some services which have to open a new window and change the content of it automatically by Javascript, here. So your proposal method “right click” doesn’t work.
As for services which won’t work in normal Franz, I applied a small patch described in https://github.com/meetfranz/franz/issues/298 by myself
@adlk
Hi. This is the one of troublesome issues, about that some services need the nativeWindowOpen property in WebView tag to work normally.
I appreciate it if this hack can be activated by some option like “useNativeWindowOpen=true” in the package.json per service because this change has side effects as you know, and I think it’s difficult to modify the current behavior of Franz. What do you think?
P.S. Sorry, I closed https://github.com/meetfranz/franz/pull/298 by my noob mistake, force push :(
Most helpful comment
Related: when I open links from gmail they open a new chrome window, but don't load the URL