Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Open webresource from javascript

(0) ShareShare
ReportReport
Posted on by 1,037

Does anyone have a javascript code that opens an HTML webresource from the ribbon and return value to calling script? 

The method should support all browsers

*This post is locked for comments

  • LeonardBertone Profile Picture
    LeonardBertone 165 on at
    RE: Open webresource from javascript

    For information, Microsoft will reject you to publish your code  if you will use xrm.internal.opendialog().

    They want we to use openWebResource()

    This is the newest information from Microsoft (today's morning)

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 Moderator on at
    RE: Open webresource from javascript

    Also you can write unsupported way -

    function (url, title) {

           var w = screen.width - 75;

           var h = screen.height - 200;

           var left = (screen.width / 2) - (w / 2);

           var top = (screen.height / 2) - (h / 2);

           var newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

           if (window.focus) {

               newWindow.focus();

           }

    Hope this helps

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 Moderator on at
    RE: Open webresource from javascript

    You can get help from below link.

    msdn.microsoft.com/.../jj602956.aspx;MSPPError=-2147217396

  • Chadi Tannous Profile Picture
    Chadi Tannous 1,037 on at
    RE: Open webresource from javascript

    Thank you for the advise. I know it is unsupported. But it works with all browsers especially if u want to return values from the web resource. I prefer to take the risk rather than using a method that doesn’t work.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 Moderator on at
    RE: Open webresource from javascript

    Hi Chadi,

    Just for your information, Xrm.Internal,OpenDialog is an unsupported way of opening a dialog. It is an internal function by Microsoft, and can be changed at any time without notification.

    You should try Xrm.Utility.openWebResource instead...

  • Verified answer
    Chadi Tannous Profile Picture
    Chadi Tannous 1,037 on at
    RE: Open webresource from javascript

    Thank you for the help but I ended up using xrm.internal.opendialog

  • VermaNitin Profile Picture
    VermaNitin 455 on at
    RE: Open webresource from javascript

    Hi,

    I'm not sure but you may give a try to the below code.

    /* Function to open the window and attach the event */

    function OpenWindowWithCallback() {

    //pass the parameters and open the dialog

    var win = window.open("yourcustomepageurl", null, "width=XX,height=XX,left=XX,top=XX,scrollbars=no");

    //attach the event

    if (typeof win.attachEvent != "undefined") {

    win.attachEvent("onbeforeunload", Callback);

    } else if (typeof win.addEventListener != "undefined") {

    win.addEventListener("beforeunload", Callback, false);

    }

    }

    /* Callback function */

     Callback= function () {

    //your custom code goes here

    }

    Let me know if it works.

    Many thanks,

    Nitin Verma

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 Moderator on at
    RE: Open webresource from javascript

    Hi Chadi,

    I don't have the exact code you are looking for but it seems straight forward. There is a method in Xrm Utility to open web resource.

    msdn.microsoft.com/.../jj602956.aspx

    Hope this helps.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans