locked
How do you center a window popup, modal window, etc. (Ribbon Workbench) RRS feed

  • Question

  • I'm trying to figure out how I can center a popup HTML form using the winParams.   I have addeda button using the Ribbon Workbench that calls my own HTML page and displays it as a popup form.  But I can only control the left/top and I do not have access to call JavaScript to compute the cordinates.

    I was thinking about adding an intermediate JavaScript function that the button will call, then display the popup window there.  But I'm wondering what the best approach might be, as I plan to use these a great deal in my CRM projects to replace a number of dialogs where I need much more functionality than the standard dialogs allow.

    Any thoughts or suggestions are much appreciated.

    Best regards,

    Jon

     

    Jon Gregory Rothlander

    Wednesday, February 19, 2014 5:36 PM

Answers

  • Hi

    If you looking through JS, then you can try something like this :

    var width = 650 ;   var height = 500;
    var posLeft = (( screen.width - width ) / 2 ) ;
    var posTop = (( screen.height - height ) / 2) ;
            
       
        window.open(url, 'name', 'status=no, width=' + width + ',height=' + height +',top=' + posTop + ',left=' +
    posLeft +',scrollbars=no,toolbars=no,menubar=no,location=no, align=center');
    

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:55 PM
    Wednesday, February 19, 2014 7:52 PM
  • I finally figured out you can use "align=center" as a window attribute to position it to the center of the screen.  This works with the Ribbon Workbench but I have not tested it in pure JavaScript, but I'd guess it would work the same.

    Jon Gregory Rothlander

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:55 PM
    Friday, February 28, 2014 2:55 PM

All replies

  • Hi

    If you looking through JS, then you can try something like this :

    var width = 650 ;   var height = 500;
    var posLeft = (( screen.width - width ) / 2 ) ;
    var posTop = (( screen.height - height ) / 2) ;
            
       
        window.open(url, 'name', 'status=no, width=' + width + ',height=' + height +',top=' + posTop + ',left=' +
    posLeft +',scrollbars=no,toolbars=no,menubar=no,location=no, align=center');
    

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:55 PM
    Wednesday, February 19, 2014 7:52 PM
  • Thanks for the sampe.  I thought window.open was support if users go through the Outlook control? Do you know if this will work through both the web and Outlook?


    Jon Gregory Rothlander

    Wednesday, February 19, 2014 9:30 PM
  • If you are using CRM 2013, and would like to just show an overlay, you can try this.

    CRM 2013 Overlay


    • Edited by Ahmad Pirani Wednesday, February 19, 2014 10:35 PM correction
    Wednesday, February 19, 2014 10:35 PM
  • Hi

    For outlook issue, refer here: 

    http://karansharma.wordpress.com/2014/02/19/windows-open-not-working-with-crm-2011-and-crm-2013/

    openStdWin method is one you need to look for !

    Wednesday, February 19, 2014 10:56 PM
  • I finally figured out you can use "align=center" as a window attribute to position it to the center of the screen.  This works with the Ribbon Workbench but I have not tested it in pure JavaScript, but I'd guess it would work the same.

    Jon Gregory Rothlander

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:55 PM
    Friday, February 28, 2014 2:55 PM