Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 4.50 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2003, 06:08 AM   PM User | #1
x_goose_x
Regular Coder

 
Join Date: Jun 2002
Location: Montreal, Canada
Posts: 644
Thanks: 0
Thanked 0 Times in 0 Posts
x_goose_x is an unknown quantity at this point
window.showModalDialog for Mozilla

Somewhat tested on Moz1.5

PHP Code:
<html>
<
head>
<
script language="JavaScript1.2" type="text/javascript">

/*
  Notes:
    1. edge & help attributes do not work.
    2. "height" & "width" must be entered before "center"
    3. if you should choose to set "center=yes" do not put in "left" and "top"
    4. Minimize button not hidden, but when clicked the window will not disappear
    5. Aside from the aforementioned, all features should react the same *fingers crossed*
    6. Still in the works, so don't expect miracles. Any problems/queries/complaints please don't hesitate.
  Email:
    [email]x_goose_x@hotmail.com[/email]
*/

dFeatures 'dialogHeight: 450px; dialogWidth: 1049px; dialogTop: 646px; dialogLeft: 4px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;';//default features

modalWin "";
function 
xShowModalDialogsURLvArgumentssFeatures )
    {
    if (
sURL==null||sURL=='')
    {
        
alert ("Invalid URL input.");
        return 
false;
    }
    if (
vArguments==null||vArguments=='')
    {
        
vArguments='';
    }
    if (
sFeatures==null||sFeatures=='')
    {
        
sFeatures=dFeatures;
    }
    if (
window.navigator.appVersion.indexOf("MSIE")!=-1)
    {
        
window.showModalDialog sURLvArgumentssFeatures );
        return 
false;
    }
    
sFeatures sFeatures.replace(/ /gi,'');
    
aFeatures sFeatures.split(";");
    
sWinFeat "directories=0,menubar=0,titlebar=0,toolbar=0,";
    for ( 
x in aFeatures )
    {
        
aTmp aFeatures[x].split(":");
        
sKey aTmp[0].toLowerCase();
        
sVal aTmp[1];
        switch (
sKey)
        {
            case 
"dialogheight":
                
sWinFeat += "height="+sVal+",";
                
pHeight sVal;
                break;
            case 
"dialogwidth":
                
sWinFeat += "width="+sVal+",";
                
pWidth sVal;
                break;
            case 
"dialogtop":
                
sWinFeat += "screenY="+sVal+",";
                break;
            case 
"dialogleft":
                
sWinFeat += "screenX="+sVal+",";
                break;
            case 
"resizable":
                
sWinFeat += "resizable="+sVal+",";
                break;
            case 
"status":
                
sWinFeat += "status="+sVal+",";
                break;
            case 
"center":
                if ( 
sVal.toLowerCase() == "yes" )
                {
                    
sWinFeat += "screenY="+((screen.availHeight-pHeight)/2)+",";
                    
sWinFeat += "screenX="+((screen.availWidth-pWidth)/2)+",";
                }
                break;
        }
    }
    
modalWin=window.open(String(sURL),"",sWinFeat);
    if (
vArguments!=null&&vArguments!='')
    {
        
modalWin.dialogArguments=vArguments;
    }
}

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


</script>

</head>
<body onFocus="checkFocus();">
<br>
<br>
<input type="button" onclick="javascript:xShowModalDialog('test.htm',this,'');" value="click">
</body>
</html> 

Last edited by x_goose_x; 12-08-2003 at 01:50 AM..
x_goose_x is offline   Reply With Quote
Old 12-08-2003, 01:47 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Checking for null is not enough:

Code:
if (modalWin!=null)
{
   self.blur();
   modalWin.focus();
}
If the popup is closed, modalWin is still not null.

Code:
if (modalWin!=null && !modalWin.closed)
{
   self.blur();
   modalWin.focus();
}
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 12-08-2003, 01:51 AM   PM User | #3
x_goose_x
Regular Coder

 
Join Date: Jun 2002
Location: Montreal, Canada
Posts: 644
Thanks: 0
Thanked 0 Times in 0 Posts
x_goose_x is an unknown quantity at this point
Thanks, forgot about that. Changes made.
x_goose_x is offline   Reply With Quote
Old 12-08-2003, 02:01 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
IMO, it's better like this:

Code:
if (typeof window.showModalDialog != 'undefined'){
  window.showModalDialog = function(sURL, vArguments, sFeatures){
    //...(no more checking for IE)
  }
}
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:19 PM.


Advertisement
Log in to turn off these ads.