Share a same popup window among different addin instances - popup

I am making an Excel add-in by Excel JavaScript API. There is a button in this add-in, clicking on it launches popup = window.open("https://localhost:3000/#/new/", "popup", "width=1000, height=1100") and popups a browser window.
Closing the workbook or the add-in will NOT systematically close the popup. So at the moment, if I open a workbook and the add-in again, and click on the button, another browser window will popup.
I am thinking if it is possible to always use the same popup for all the excel/add-in instances. We could use localstorage to share information among different excel/add-in instances, but I am not sure if it is possible to save the popup/window there.
Does anyone have any good idea to achieve this?

For Office Add-ins, you should be using the built in Dialog API. This API ensures popups are properly handled regardless of platform (i.e. across browsers, mobile and desktop clients).
The Dialog object supports a close method, allowing you to close any open dialogs from the parent taskpane.

Related

How to close the Browser Window using ZK framework?

I need to close the Browser Window Tab, please note not the window widget but the Browser window tab, using ZK framework version CE-9.0.0.
I have already tried the following code segments but no luck:
Clients.confirmClose(null);
Executions.deactivate(page.getDesktop());
page.setComplete(true);
page.removeComponents();
page.invalidate();
Is there any API or way to achieve this using ZK and/or JavaScript?
Is there any way to get the reference to the browser window tab, so that it can be closed programmatically, in ZK and/or JavaScript?
Please note: This window tab is opened manually & not by JavaScript or any other program.
Thanks,
RAS
Close the browser tab from a server directly is not allowed. But you can show a modal window to ask a user to close a browser tab like:
<zk xmlns:ca="client/attribute">
...
<window mode="modal" title="Close the browser tab">
<button label="Yes" ca:onClick="window.close();"/>
</window>
</zk>
Because close() is invoked by users, it will close the browser tab. This could be an alternative. Although it doesn't close a browser tab directly, the modal window covers the whole page. Users can't do anything but to click "yes", so I think most users will just click "yes" to close.
I found it works in Chrome 80, but will fail at Chrome 81. So it's not a good way
The JS to close a window is window.close(), this is a well documented standard browser API. (also answered here)
From a ZK application (server-side) you can call this script via:
Clients.evalJavaScript("window.close()");
However this browser API has strict limitations: In modern browsers you can only close windows via close() that were also opened by javascript. So you can't close the current window in case the user navigated there manually - no way around that, except for using an old browser, which I won't recommend.
e.g. that's what you'll get in Chrome (#81)

TWebBrowser in Delphi 10.2 doesn't show a form as it should

I make a multi-device app that has a TWebBrowser component.
If i write this code
WebBrowser1.Navigate('https://google.com');
it opens the form as it should be.
But if i write this code
WebBrowser1.Navigate(edit1.text);
where edit1.text=the URL of a GoogleForms form (=https://docs.google.com/forms/d/e/1FAIpQLScLDCv_LeYJzvMoxnmvt_gN_gqeup7_vbU8VLaC-qXNPEGMIQ/viewform?vc=0&c=0&w=1&fbzx=3551763952707733753), it shows the form confused (the dropdown components as list of text, the "submit" button as text etc) like this :
is there a solution, please ?
PS. the form is opened in Internet Explorer (and Google) right.
The reason why this happens is that by default TWebBrowser component is opening web pages in compatiblity mode. This prevents myn moder web pages to show properly.
So in order to avoid this you need to opt in to the browser emulation feature using the documented registry key.
You can find more info about this on the link bellow
https://stackoverflow.com/a/25843958/3636228

office js change DOM loaded in task pane

I'm developing an office add-in using office-js (not using VSTO) and I want to access the DOM loaded in the task pane from the java script function-file used in the manifest extension points .
Yes, you can access the DOM loaded in the task pane from your JavaScript function-file. Think of it as if you have two browser windows or tabs and you want to communicate between them. Since the windows don't have access to a reference for one another, postMessage isn't a good solution. One option would be to use localStorage, which triggers an event on all same-domain pages when it changes.
Yes, you can access the DOM loaded in the task pane from your JavaScript function-file. Think of it as if you have two browser windows or tabs and you want to communicate between them. One option would be to use the postMessage() API to notify the task pane and include any information you'd like.
Edit: see my other answer: this solution isn't feasible since the window reference isn't available.

How to open a popup window with an external url in a chrome app? (like window.open with _blank)

I need to open an url on a new and single tab chrome window, as you would normally do with window.open and "_blank", but when done inside a chrome app, the url is opened in a new tab of an already running chrome, ignoring all the window features options (width, height, etc).
Are we doing something wrong or is this a chrome app constrain? Any way to solve it?
Best regards
Sergio
You have two options.
Use a proper API to open a tab, chrome.browser.openTab, but that doesn't give you an ability to open it in a separate window. Such an option would probably be a nice addition, you can try submitting a feature request for it.
Open an app window with a local HTML file that embeds the required web content inside a <webview>. You then have full control over appearance, but lose access to browser's conveniences like cookie/password store of the current user, and have to implement some things yourself like dialog boxes.
I'm afraid a Chrome app cannot interact with the browser itself in a more detailed way by design.

Where should I open initial dialogs in an Eclipse application?

I have an Eclipse RCP application. When the application is started I want to immediately present the user with a login dialog. Where is the best place to do this?
I've tried to use various hooks in the WorkbenchAdvisor and WorkbenchWindowAdvisor, but all of these open a dialog before the application had a task bar icon. In this case the dialog can easily be moved behind other windows and there will be no visual indication that the application is open, and the user might open several instances of the application by mistake.
I could force the dialog to be on top, but that's not a good solution. I want a proper modal dialog. A good example of such a dialog is Firefox's "save page as" dialog. When this dialog is present it is always in front of the main browser window; you must complete or close the dialog before you can effectively resume browsing the web. However, this "save page as" dialog doesn't force itself to be on top of every window, just the browser.
You can make a splash screen your login dialog: see an example here.
First: Is it allowed to have multiple instances open? If not, you have to implement independent from the Login-Dialog-Problem something that prevents opening several instance. Take a look here (btw: I made good experiences with the server-socket thing).
Second: If you overwrite #postWindowOpen in your ApplicationWorkbenchWindowAdvisor the application is up and running (including task-item). The only drawback is that your views are already opened, you have to reload them after a successful login.