Wednesday 1 February 2012

Using window.showModalDialog in IE9 - CRM Customization

Hi everyone ( I hope someone takes a look at this blog really..),

Here is a very small tip for you guys to control how your window dialog appear in CRM.

The scenario here is you would like to create a new button in CRM ribbon. When you click the button, a window dialog will be pop up.

 The solution is writing a javascript function to show up the window dialog using window.showModalDialog method. All about this method could be found in this link: http://msdn.microsoft.com/en-us/library/ie/ms536759(v=vs.85).aspx

However, your window dialog appeareance depends on kind of browser you use (IE, Firefox, Chrome, etc..). Now i'm using IE9, then figure out one problem with it.

As you see the following javascript:

 window.showModalDialog(url, null, "dialogHeight:600px;dialogWidth:800px;center:yes; resizable:1;maximize:1;minimize:1;status:no;scroll:no" );

In IE9, all the features defined in the javascript above (underlined) could not be fired. Then you have to enbale the Compatibility View in IE9 in order to run it correctly.

To enable Compatibility View in IE9, the following steps:
- Alt + T to see the toolbars
- Go to Tools tab, you will see Compatibility View Setting


 - Then adding your website (here is your CRM) and select Display all website as shown in the below pic



So now, run your javascript again and see your window dialog appear correctly as your code !

I hope it'll be useful.



2 comments:

  1. Thank you! I was beating my head against the wall on this one and finally found your helpful post. Solved my issue!

    ReplyDelete
  2. One small problem with your solution.
    When, and as far as I know this will happen sooner rather than later, this method will get deprecated by the all other browsers but IE. What will happen with those who used your advice?
    On top of that forcing IE into compatibility mode is not the solution because you limiting your visitors to older version instead of solving problem on your site. IE11 does not have compatibility mode at all. What you going to do with that one?
    Thanks

    ReplyDelete