showModalDialog in IE 6

G

Guest

We have a new Java JSP application that opens several modal dialog boxes.
All have different sizes. We execute a function to open the box. In IE, the
first box you open determines the size. All other boxes open with the same
size regardless of the parameters. This doesn't happen in Firefox. I will
paste the JS and examples below. Any suggestions?

H Manary

examples:
xShowModalDialog( '/tde/MergePatServlet', this,
'dialogheight:150px;dialogwidth:350px' );

xShowModalDialog( '/tde/CopyTrialServlet', this,
'dialogheight:420px;dialogwidth:520px' );

// dialogBox.js

var dFeatures =
'dialogHeight=450px,dialogWidth=450px,dialogTop=100px,dialogLeft=100px,help=no,resizable=no,status=yes,menubar=no,toolbar=no,location=no,directories=no,modal=yes,dialog=yes';//default features

var modalWin = "";
var pHeight = 0;
var pWidth = 0;
var bCenter = false;
var MSIE = false;

function xShowModalDialog( sURL, vArguments, sFeatures )
{
try
{
if( sURL == null || sURL == '' )
{
alert ("Invalid URL input.");
return false;
}
if( vArguments == null || vArguments == '' )
{
vArguments='';
}
if( window.navigator.appVersion.indexOf( "MSIE" ) != -1 )
{
MSIE = true;
}
aFeatures = sFeatures.replace( / /gi,'' ).split( ";" );

for( x in aFeatures )
{
aTmp = aFeatures[x].split( ":" );
sKey = aTmp[0].toLowerCase();
sVal = aTmp[1];
switch( sKey )
{
case "dialogheight":
dFeatures = dFeatures.replace( /(height=)\d+.?.?\,?/gi, '$1'
+ sVal + "," );
pHeight = sVal;
break;
case "dialogwidth":
dFeatures = dFeatures.replace( /(width=)\d+.?.?\,?/gi, '$1'
+ sVal + "," );
pWidth = sVal;
break;
case "dialogtop":
dFeatures = dFeatures.replace( /(top=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "dialogleft":
dFeatures = dFeatures.replace( /(left=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "resizable":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/resizable=[yes|1|no|0]\,/gi,'resizable=' + sVal + "," );
break;
case "status":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/status=[yes|1|no|0]\,/gi,'status=' + sVal + "," );
break;
case "help":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/help=[yes|1|no|0]\,/gi,'help=' + sVal + "," );
break;
case "center":
if ( sVal.toLowerCase() == "yes" )
{
bCenter = true;
}
break;
}
}
if( bCenter )
{
if( pHeight.indexOf("px")!= -1 && pWidth.indexOf("px")!= -1 )
{
pHeight = pHeight.replace( /px/gi,'' );
pWidth = pWidth.replace( /px/gi,'' );
dFeatures = dFeatures.replace( /(top=)\d*px/gi,'$1' + ( (
window.screen.height-pHeight)/ 2 ) + "px" );
dFeatures = dFeatures.replace( /(left=)\d*px/gi,'$1' + ( (
window.screen.width-pWidth ) / 2 )+ "px" );
}
}

if( MSIE ) // Internet Explorer
{
if( vArguments != null && vArguments != '' )
{
modalWin.dialogArguments = vArguments;
}
dFeatures = dFeatures.replace( /,/gi,';' ).replace( /=/gi,': ' ); //
make it a style
//alert( "Internet Explorer: " + sURL + " - " + vArguments + "\r\n" +
dFeatures );
window.showModalDialog( sURL, vArguments, dFeatures );
return false;
}
else // FF, Moz, Netscape
{
dFeatures = dFeatures.replace( /dialog([A-Za-z]){1}/gi, "$1"
).toLowerCase(); //change dialogXXX to XXX
//alert( "FF, Moz, Netscape: " + sURL + "\r\n" + dFeatures );
modalWin=window.open( String( sURL ), "", dFeatures );
}
//if( vArguments != null && vArguments != '' )
//{
// modalWin.dialogArguments = vArguments;
//}
}
catch( e )
{
alert( e );
}
}

function checkFocus()
{
if( window.navigator.appVersion.indexOf("MSIE")==-1 )
{
if( modalWin != null && !modalWin.closed )
{
self.blur();
modalWin.focus();
}
}
}
 
R

Rob ^_^

Hi H,

I am just giving a quick answer, I have copied your code and I will sandbox
it sometime today, but my first guess is the use of 'this' as the second
dialog argument. Try removing it from the arguement parameters

eg
xShowModalDialog( '/tde/MergePatServlet', this,
'dialogheight:150px;dialogwidth:350px' );

becomes

xShowModalDialog( '/tde/MergePatServlet', ,
'dialogheight:150px;dialogwidth:350px' );


H Manary said:
We have a new Java JSP application that opens several modal dialog boxes.
All have different sizes. We execute a function to open the box. In IE,
the
first box you open determines the size. All other boxes open with the
same
size regardless of the parameters. This doesn't happen in Firefox. I
will
paste the JS and examples below. Any suggestions?

H Manary

examples:
xShowModalDialog( '/tde/MergePatServlet', this,
'dialogheight:150px;dialogwidth:350px' );

xShowModalDialog( '/tde/CopyTrialServlet', this,
'dialogheight:420px;dialogwidth:520px' );

// dialogBox.js

var dFeatures =
'dialogHeight=450px,dialogWidth=450px,dialogTop=100px,dialogLeft=100px,help=no,resizable=no,status=yes,menubar=no,toolbar=no,location=no,directories=no,modal=yes,dialog=yes';//default
features

var modalWin = "";
var pHeight = 0;
var pWidth = 0;
var bCenter = false;
var MSIE = false;

function xShowModalDialog( sURL, vArguments, sFeatures )
{
try
{
if( sURL == null || sURL == '' )
{
alert ("Invalid URL input.");
return false;
}
if( vArguments == null || vArguments == '' )
{
vArguments='';
}
if( window.navigator.appVersion.indexOf( "MSIE" ) != -1 )
{
MSIE = true;
}
aFeatures = sFeatures.replace( / /gi,'' ).split( ";" );

for( x in aFeatures )
{
aTmp = aFeatures[x].split( ":" );
sKey = aTmp[0].toLowerCase();
sVal = aTmp[1];
switch( sKey )
{
case "dialogheight":
dFeatures = dFeatures.replace( /(height=)\d+.?.?\,?/gi,
'$1'
+ sVal + "," );
pHeight = sVal;
break;
case "dialogwidth":
dFeatures = dFeatures.replace( /(width=)\d+.?.?\,?/gi, '$1'
+ sVal + "," );
pWidth = sVal;
break;
case "dialogtop":
dFeatures = dFeatures.replace( /(top=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "dialogleft":
dFeatures = dFeatures.replace( /(left=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "resizable":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/resizable=[yes|1|no|0]\,/gi,'resizable=' + sVal + "," );
break;
case "status":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/status=[yes|1|no|0]\,/gi,'status=' + sVal + "," );
break;
case "help":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/help=[yes|1|no|0]\,/gi,'help=' + sVal + "," );
break;
case "center":
if ( sVal.toLowerCase() == "yes" )
{
bCenter = true;
}
break;
}
}
if( bCenter )
{
if( pHeight.indexOf("px")!= -1 && pWidth.indexOf("px")!= -1 )
{
pHeight = pHeight.replace( /px/gi,'' );
pWidth = pWidth.replace( /px/gi,'' );
dFeatures = dFeatures.replace( /(top=)\d*px/gi,'$1' + ( (
window.screen.height-pHeight)/ 2 ) + "px" );
dFeatures = dFeatures.replace( /(left=)\d*px/gi,'$1' + ( (
window.screen.width-pWidth ) / 2 )+ "px" );
}
}

if( MSIE ) // Internet Explorer
{
if( vArguments != null && vArguments != '' )
{
modalWin.dialogArguments = vArguments;
}
dFeatures = dFeatures.replace( /,/gi,';' ).replace( /=/gi,': ' ); //
make it a style
//alert( "Internet Explorer: " + sURL + " - " + vArguments + "\r\n" +
dFeatures );
window.showModalDialog( sURL, vArguments, dFeatures );
return false;
}
else // FF, Moz, Netscape
{
dFeatures = dFeatures.replace( /dialog([A-Za-z]){1}/gi, "$1"
).toLowerCase(); //change dialogXXX to XXX
//alert( "FF, Moz, Netscape: " + sURL + "\r\n" + dFeatures );
modalWin=window.open( String( sURL ), "", dFeatures );
}
//if( vArguments != null && vArguments != '' )
//{
// modalWin.dialogArguments = vArguments;
//}
}
catch( e )
{
alert( e );
}
}

function checkFocus()
{
if( window.navigator.appVersion.indexOf("MSIE")==-1 )
{
if( modalWin != null && !modalWin.closed )
{
self.blur();
modalWin.focus();
}
}
}
 
G

Guest

I tried to remove the "this". I get syntax errors when the page loads, the
hour glass stays, when I click the button I get "error: Object expected"

Rob ^_^ said:
Hi H,

I am just giving a quick answer, I have copied your code and I will sandbox
it sometime today, but my first guess is the use of 'this' as the second
dialog argument. Try removing it from the arguement parameters

eg
xShowModalDialog( '/tde/MergePatServlet', this,
'dialogheight:150px;dialogwidth:350px' );

becomes

xShowModalDialog( '/tde/MergePatServlet', ,
'dialogheight:150px;dialogwidth:350px' );


H Manary said:
We have a new Java JSP application that opens several modal dialog boxes.
All have different sizes. We execute a function to open the box. In IE,
the
first box you open determines the size. All other boxes open with the
same
size regardless of the parameters. This doesn't happen in Firefox. I
will
paste the JS and examples below. Any suggestions?

H Manary

examples:
xShowModalDialog( '/tde/MergePatServlet', this,
'dialogheight:150px;dialogwidth:350px' );

xShowModalDialog( '/tde/CopyTrialServlet', this,
'dialogheight:420px;dialogwidth:520px' );

// dialogBox.js

var dFeatures =
'dialogHeight=450px,dialogWidth=450px,dialogTop=100px,dialogLeft=100px,help=no,resizable=no,status=yes,menubar=no,toolbar=no,location=no,directories=no,modal=yes,dialog=yes';//default
features

var modalWin = "";
var pHeight = 0;
var pWidth = 0;
var bCenter = false;
var MSIE = false;

function xShowModalDialog( sURL, vArguments, sFeatures )
{
try
{
if( sURL == null || sURL == '' )
{
alert ("Invalid URL input.");
return false;
}
if( vArguments == null || vArguments == '' )
{
vArguments='';
}
if( window.navigator.appVersion.indexOf( "MSIE" ) != -1 )
{
MSIE = true;
}
aFeatures = sFeatures.replace( / /gi,'' ).split( ";" );

for( x in aFeatures )
{
aTmp = aFeatures[x].split( ":" );
sKey = aTmp[0].toLowerCase();
sVal = aTmp[1];
switch( sKey )
{
case "dialogheight":
dFeatures = dFeatures.replace( /(height=)\d+.?.?\,?/gi,
'$1'
+ sVal + "," );
pHeight = sVal;
break;
case "dialogwidth":
dFeatures = dFeatures.replace( /(width=)\d+.?.?\,?/gi, '$1'
+ sVal + "," );
pWidth = sVal;
break;
case "dialogtop":
dFeatures = dFeatures.replace( /(top=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "dialogleft":
dFeatures = dFeatures.replace( /(left=)\d+.?.?\,?/gi,'$1' +
sVal + "," );
break;
case "resizable":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/resizable=[yes|1|no|0]\,/gi,'resizable=' + sVal + "," );
break;
case "status":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/status=[yes|1|no|0]\,/gi,'status=' + sVal + "," );
break;
case "help":
sVal = sVal.toLowerCase();
dFeatures = dFeatures.replace(
/help=[yes|1|no|0]\,/gi,'help=' + sVal + "," );
break;
case "center":
if ( sVal.toLowerCase() == "yes" )
{
bCenter = true;
}
break;
}
}
if( bCenter )
{
if( pHeight.indexOf("px")!= -1 && pWidth.indexOf("px")!= -1 )
{
pHeight = pHeight.replace( /px/gi,'' );
pWidth = pWidth.replace( /px/gi,'' );
dFeatures = dFeatures.replace( /(top=)\d*px/gi,'$1' + ( (
window.screen.height-pHeight)/ 2 ) + "px" );
dFeatures = dFeatures.replace( /(left=)\d*px/gi,'$1' + ( (
window.screen.width-pWidth ) / 2 )+ "px" );
}
}

if( MSIE ) // Internet Explorer
{
if( vArguments != null && vArguments != '' )
{
modalWin.dialogArguments = vArguments;
}
dFeatures = dFeatures.replace( /,/gi,';' ).replace( /=/gi,': ' ); //
make it a style
//alert( "Internet Explorer: " + sURL + " - " + vArguments + "\r\n" +
dFeatures );
window.showModalDialog( sURL, vArguments, dFeatures );
return false;
}
else // FF, Moz, Netscape
{
dFeatures = dFeatures.replace( /dialog([A-Za-z]){1}/gi, "$1"
).toLowerCase(); //change dialogXXX to XXX
//alert( "FF, Moz, Netscape: " + sURL + "\r\n" + dFeatures );
modalWin=window.open( String( sURL ), "", dFeatures );
}
//if( vArguments != null && vArguments != '' )
//{
// modalWin.dialogArguments = vArguments;
//}
}
catch( e )
{
alert( e );
}
}

function checkFocus()
{
if( window.navigator.appVersion.indexOf("MSIE")==-1 )
{
if( modalWin != null && !modalWin.closed )
{
self.blur();
modalWin.focus();
}
}
}
 
Top