Resize SharePoint Dialog Boxes dynamically based on screen width/height

If you are using SharePoint 2013 Dialog boxes on a responsive website then ensure that you include the following JQuery code snippet to ensure that Dialog box width and height automatically adjusts as per device screen width and height.

var dialogOptions = {
   url: newDialog.WebUrl + '/MyDialog/ThisIsADialogBox.aspx',
   title: 'Dialog Box Resizing Sample',
   allowMaximize: false,
   showClose: true,
   height: 520,

Once the Dialog box is loaded then you invoke a function similar to one below (from the page contained in the dialog):
function resizeDialogWorkspace() {
  //Check the Windows height and if smaller than dialog then set the height of dialog less than window height
   if (window.innerHeight < $('#s4-workspace').height()) {
     $('#s4-workspace').height(window.innerHeight - 6);