web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Xrm.Navigation.openWebResource center of screen

(0) ShareShare
ReportReport
Posted on by 175

Hi, I am using the latest method in d365 v9 UCI to open the html webresource:
Xrm.Navigation.openWebResource

The issue is i want it to open at the center of the screen, by default it appears at the corner. windowOptions is only taking height and width. Can anyone help me on this please ?
var windowOptions = { height: 200, width: 600 };

Xrm.Navigation.openWebResource(webresourceName, windowOptions, param)

//P.S i tried with top and left but no luck ... var windowOptions = { height: 200, width: 600, left: 430, top: 271 }popup.png

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi aj,

    I tested your code directly and the popup window could be in center position among Chrome(75.0), Firefox(67.0), Edge(44).

    My version: 9.1.0.5826.

    You could still replace Xrm function with native JS function window.open to call pop-up window and add top param to change it position.

    var url = Xrm.Page.context.getClientUrl();

    var resourceName = 'new_demopage';

    var resourcePath = url + '//WebResources/' + resourceName;

    window.open(resourcePath, '_blank', 'width=600,height=200,top=200');

    It worked for me.

    Regards,

    Clofly

  • innovativeaj Profile Picture
    175 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi Clofly,

    Thanks for your help. window.open is not a supported way. As for the version, i am also using chrome 75.0.3770.100 and D365 9.1.0.5826 but for me it opens in the corner. Can u please confirm that you tested with the exact same code and it opened in the center ?

    Thanks a lot!

  • cloflyMao Profile Picture
    25,210 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi aj,

    Yes, I tested with the exact same code yours.

    111.JPG

    7411.JPG

    And I tested with both HTML(screenshot) and image web resource, in Account > account form.

    Regards,

    Clofly

  • Dharanidharan Profile Picture
    638 Super User 2025 Season 2 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi,

    You need to set the top and left value to the window.open() method it will automatically bring the pop up to the center of the screen. Below is the method for your reference:

    var openCenteredWindow = function(url, name, width, height) {
            var left = parseInt((screen.availWidth / 2) - (width / 2));
            var top = parseInt((screen.availHeight / 2) - (height / 2));
            var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
            closepopup = window.open(url, name, windowFeatures);
        };

    Thanks & Regards,

    Dharani

  • innovativeaj Profile Picture
    175 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi Clofly,

    I appreciate your prompt response, thanks a lot... but the issue is in UCI as I had mentioned earlier also. I tried with webrefresh and it opens in the center as you have shown in the image. In UCI it opens in the corner, don't know how to resolve that.

  • innovativeaj Profile Picture
    175 on at
    RE: Xrm.Navigation.openWebResource center of screen

    thanks Dharani, but this is not the supported way.

  • cloflyMao Profile Picture
    25,210 on at
    RE: Xrm.Navigation.openWebResource center of screen

    Hi aj,

    I'm sorry about that I not mentioned it.

    So it's same for me that pop-up window not in center in UCI.

    Unfortunately, we couldn't set it position with supported way.

    Regards,

    Clofly

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans