By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,299 Members | 1,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,299 IT Pros & Developers. It's quick & easy.

Alternate for Showmodaldialog in mozilla firefox

P: 63
Hi all.
I have used showmodaldialog for a popup window. it works fine in IE but shows :Error: showModalDialog is not defined.
I have gone through many forums but haven't got satisfactory solution.

Moreover i dont want the popupwindow to be closed manually .It gets closed automatically as the time fixed for its display gets over.

This functionality is working fine in IE but if someone could help me out to run it in Mozilla and other browsers,it would be great.

Below is my code:

[HTML]function getUpload(sForm){
{
var synclose=null;

while(synclose==null)
{
var sURL = sForm;
var rst = showModalDialog(sURL, '', 'dialogWidth:600px; toolbar:0; dialogHeight:300px; status:0; resizable=0;');
};
}
}
</script>
</head><?php
$mode=1;
if($mode==1)
{
?>
<body onLoad="getUpload('syncpop.php')"> </body>

<?php
}
?></html>
[/HTML]

//Here is the syncpop.php page

[HTML]
<html>
<head>
<META HTTP-EQUIV=REFRESH CONTENT=2>
<body>
<? $mode=1;
if ($mode==1){?>
<script language="javascript">
document.write("Synchonizing, please wait...");
</script>
<? }
if($mode==0){?>
<script type="text/javascript">
alert('Last Synchronizaton completed successfully');
window.returnValue = "Success!!";
window.close();
</script>
<? }?></body>
</html>[/HTML]

The code involves a little bit of php but it hardly makes difference..i want the javascript function only that could solve my above mentioned purpose.

Thanks and Regards
TechnoAtif
Jul 1 '08 #1
Share this Question
Share on Google+
13 Replies

gits
Expert Mod 5K+
P: 5,390
for other browsers you have to create a custom DHTML-(div)-dialog, that you could use for IE too. developing a page for IE first and then trying to adapt it to standards-compliant browsers is much more difficult then the other way round ...

kind regards
Jul 1 '08 #2

acoder
Expert Mod 15k+
P: 16,027
showModalDialog is now supported in Firefox 3, but for older versions and other browsers you will need to create your own as gits mentioned.
Jul 1 '08 #3

gits
Expert Mod 5K+
P: 5,390
hmmm ... it seems that safari 3.1 supports it too ...

kind regards
Jul 1 '08 #4

acoder
Expert Mod 15k+
P: 16,027
So that leaves Opera from the major browsers.
Jul 1 '08 #5

P: 63
[HTML]<title>Popup WebPage</title>
<script language="javascript">
function makePopup(url, width, height, overflow)
{
if (width > 640) { width = 640; }
if (height > 480) { height = 480; }
if (overflow == '' || !/^(scroll|resize|both)$/.test(overflow))
{
overflow = 'both';
}
var win = window.open(url, '',
'width=' + width + ',height=' + height
+ ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ?
'yes' : 'no')
+ ',resizable=' + (/^(resize|both)$/.test(overflow) ?
'yes' : 'no')
+ ',status=yes,toolbar=no,menubar=no,location=no'
);
return win;
}


</script>
<?
$mode=1;
if($mode==1){?>
<html><body onLoad="makePopup(syncpop.php', 480, 240, 'resize')" ></body></html>
<? } ?>

//syncpop.php

window.onbeforeunload = function (evt) {
var message = '';
if (typeof evt == '') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}


[/HTML]






this code works but not completely...any suggestions??
Jul 1 '08 #6

acoder
Expert Mod 15k+
P: 16,027
What do you mean by "not completely"? What doesn't work?
Jul 1 '08 #7

P: 63
I want the popup window not to get closed ,even on click of the close option untill the time fixed for its display does not gets over.
Using Window.onbeforeunload prompts a dialog box and the window can be closed on clicking the ok button . I dont want it to close .
Any suggestions?
Jul 2 '08 #8

gits
Expert Mod 5K+
P: 5,390
then your best bet is certainly a custom DHTML-popup ... since you even should use it to support all! browsers ... i guess you cannot avoid closing a 'real' window ...

kind regards
Jul 2 '08 #9

P: 63
plz dont tell me that their is no solution to this issue. I have to do it for th client

plz find some solution.
Jul 2 '08 #10

gits
Expert Mod 5K+
P: 5,390
the DHTML-popup IS a solution ... and certainly the best one!
Jul 2 '08 #11

P: 63
Ok i'll try it. lets hope for the best. If you have done some work on it kindly share with me. Alongside i'm trying it on my side too .

Thanks
Jul 2 '08 #12

gits
Expert Mod 5K+
P: 5,390
you just have to create a div onclick at whatever you want to open it. use dom-methods like document.createElement('div'); for example. then apply any apropriate css (don't forget the z-index!) to it and append needed elements, like an iframe to load a page or whatever. set a timeout when you need to have it closed after some time ...

another possibility is to create it staticly and set its visibility to hidden, and onclick of the element you need, just toggle its visibility-property.

kind regards
Jul 2 '08 #13

acoder
Expert Mod 15k+
P: 16,027
If you want nice-looking popup-divs that have already been written, try GreyBox, ThickBox, SlightlyThickerBox, ShadowBox, iBox or other LightBox clones that support displaying of HTML and not just images as the original LightBox does.
Jul 2 '08 #14

Post your reply

Sign in to post your reply or Sign up for a free account.