Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Wednesday, 30 May 2012

DialogWidth and DialogHeight not working on chrome for showModalDialog

window.showModalDialog is ignoring dialogWidth and dialogHeight on Chrome but works fine on other browsers such as IE, firefox etc. After some tweaking I have found that dialogWidth and dialogHeight should not have "px" in the value ie.. "dialogWidth:100;dialogHeight:200" but other browsers need to have "px" such as "dialogWidth:100px;dialogHeight:200px"

Here is a simple function that can help

 function ModalDialog(sURL, vArguments, ModalDialogHeight, ModalDialogWidth) {
        var sFeatures;

        if (window.showModalDialog) {
            if (!navigator.userAgent.toLowerCase().match('chrome')) {
                ModalDialogWidth += "px";
                ModalDialogHeight += "px";
            }
            sFeatures = "status:no;center:yes;dialogWidth:" + ModalDialogWidth + ";dialogHeight:" + ModalDialogHeight + ";resizable:yes;";
            var returnResult = window.showModalDialog(sURL, vArguments, sFeatures);
            if (returnResult) {
                return returnResult;
            }
        }
        else {
            sFeatures = "status=no,width=" + ModalDialogWidth + ",height=" + ModalDialogHeight + ",menubar=no,scrollbars=no";
            window.margs = vArguments;
            window.open(sURL, "_blank", sFeatures);
        }
    }


After growing wildly for years, the field of computing appears to be reaching its infancy. ~John Pierce

2 comments:

Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers