Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Xrm.Navigation.openWebResource center of screen

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

  • cloflyMao Profile Picture
    cloflyMao 25,198 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

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

    thanks Dharani, but this is not the supported way.

  • innovativeaj Profile Picture
    innovativeaj 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.

  • Dharanidharan Profile Picture
    Dharanidharan 390 User Group Leader 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

  • cloflyMao Profile Picture
    cloflyMao 25,198 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

  • innovativeaj Profile Picture
    innovativeaj 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
    cloflyMao 25,198 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

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans