Search code examples
javascriptjquerywindow.opendynamics-365unified-service-desk

Open popup window instead of new tab/window in USD hosted control


How to open a popup window in USD hosted control ?

Javascript code:

<script>
    function basicPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=300,width=700,left=50,top=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes')
    }

</script>
<a href="https://www.google.com" onclick="basicPopup(this.href);return false">Open a popup window</a>

USD Window navigation rules

Route Type - Popup, Action - Show Outside , Destination - Tab

Hosting Type: Edge Process/Chrome Process.

Issue: When launching the above JS snippet in a browser, it worked as expected (popup opens with given dimensions and child window able to communicate to parent window with Post message ) whereas the same code integrated with USD, the popup launches in new tab and newly opened window unable to communicate to parent window (window.open() returns null)

Any ideas as to what I'm missing?


Solution

  • If you let USD host all of your browser processes and unify your browser types, you may be able to access your parent windows as desired.

    Create a "destination" / "child" hosted control that can receive your target navigation. Make all browsers Chrome, and if you can't do that for whatever reason, hopefully you can make them all Edge instead. In your Window Navigation Rule, instead of Show Outside, use the action Route Window, and set the Target Tab to the new child browser hosted control. Put the child browser on FloatingPanel if you prefer not to host it as a MainPanel tab.

    Also, not to be redundant, but having noticed your "Chrome/Edge" hybrid hosting summary above, I would suggest doing as much as possible to eliminate the hosting of multiple browser types throughout your configuration(s). I would assume that a USD-hosted browser handing off to a "Windows hosted" browser could complicate (prevent?) your ability to find the parent window, even if the browser type inside and outside of USD are the same. To my knowledge, USD and Windows use different versions of Edge (USD has yet to integrate the new Edge, and it might never) and USD manages its own Chromium instances. I assume "Show Outside" in Chrome does not launch a new CEF process from your USD application folder, but rather just hands off to Windows, which then invokes the Chrome stand-alone application (if it is your OS default browser). There may(?) be value in testing various combinations of browser types here, if you are committed to the "Show Outside" paradigm for whatever reason.