Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > javascript: how to run showModalDialog() on safari on mac osx

javascript: how to run showModalDialog() on safari on mac osx
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2005
Status: Offline
Reply With Quote
Dec 12, 2005, 03:14 AM
 
window.showModalDialog() is a function to show a modal dialog which is supported by IE6.0 of windows platform. My company want to transplant some jsp which running on IE6.0 on windows platform to the safari on mac osx. But I find that the function window.showModalDialog() is not supportted by safari, I can't find any useful things by Google . If you know the way to sovle the problem . help me, please , thanks a lot.

myemail:meng.yu@huawei.com
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 12, 2005, 01:56 PM
 
It works for me in Safari. Maybe if you gave a code example, we could figure out what you're doing wrong?

(Incidentally, I predict a move to the Web Developer forum.)
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
m45023  (op)
Fresh-Faced Recruit
Join Date: Dec 2005
Status: Offline
Reply With Quote
Dec 13, 2005, 04:00 AM
 
thanks for your help,my friends!

I'm redesign a web site to be compatible with Safari.
20% customers use safari & firefox and 80% customers use IE on windows.

I google for: showModalDialog replacement
or: showModalDialog alternative

I find a way but it's unwork on safari.
In parent window ,we can add a function on onfocus event of the html body element. When the parent window is selected , the event will call a function.In the function, if child window is open, the function will focus on the child window.
the code is:
<html>
<head>
<script language="JavaScript1.2" type="text/javascript">
dFeatures = 'dialogHeight: 450px; dialogWidth: 1049px; dialogTop: 646px; dialogLeft: 4px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;';//default features

modalWin = "null";
function xShowModalDialog( sURL, vArguments, sFeatures )
{
if (sURL==null||sURL=='')
{
alert ("Invalid URL input.");
return false;
}
if (vArguments==null||vArguments=='')
{
vArguments='';
}
if (sFeatures==null||sFeatures=='')
{
sFeatures=dFeatures;
}
alert("window.navigator.appVersion="+window.naviga tor.appVersion);
if (window.navigator.appVersion.indexOf("MSIE")!=-1)
{
window.showModalDialog ( sURL, vArguments, sFeatures );
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()
{
try{
if (window.navigator.appVersion.indexOf("MSIE")==-1)
{

if (modalWin!="null")
{
if(!modalWin.closed){
self.blur();
modalWin.focus();

}
}
}
}catch(e){alert(e);}
}


</script>

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

the code can work on IE6.0 & firefox , but not work on safari!
I find in the SafariHTMLRef(http://developer.apple.com/documenta.../SafariHTMLRef) & SafariJSRef(http://developer.apple.com/documenta...ce/SafariJSRef)
.the are the discript of onFocus events,

onFocus
<element onFocus="handler(args);" ...>
Discussion
Called when the associated element receives keyboard input focus.Can only be used with elements
that can receive keyboard input such as <input>,<textarea>,or<select>.
Availability
Availablein MacOSXv10.2withSafari1.0and later.
Availablein MacOSXv10.2.7andlater.

It's the answer that onfocus can't work on safari , the onfocus events only receives the keyboard input, so this way can't replace the showmodaldialog method.

I try to use onMouseOver event to replace onFocus event, but find it faults:
onMouseOver event can be called and focus on the child window,but the button on parent window can still be clicked ,it's not modal.

the problem is still not sovled.

If you have a good idea, please help me!
Thanks for your help!
     
Mac Elite
Join Date: Jul 2002
Status: Offline
Reply With Quote
Dec 13, 2005, 05:51 PM
 
Well, I get this error in Safari's JavaScript Console: Object (result of expression checkFocus) does not allow calls. But I don't know what that means, so... :shrug:

Next time you post code use the code tags.

Oh, and that's in WebKit Safari. Safari 2.0.2 doesn't show that error, but it may still be affected by it.
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2