469,641 Members | 1,129 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Alternate for Showmodaldialog in mozilla firefox

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
13 10833
gits
5,390 Expert Mod 4TB
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
16,027 Expert Mod 8TB
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
5,390 Expert Mod 4TB
hmmm ... it seems that safari 3.1 supports it too ...

kind regards
Jul 1 '08 #4
acoder
16,027 Expert Mod 8TB
So that leaves Opera from the major browsers.
Jul 1 '08 #5
[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
16,027 Expert Mod 8TB
What do you mean by "not completely"? What doesn't work?
Jul 1 '08 #7
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
5,390 Expert Mod 4TB
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
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
5,390 Expert Mod 4TB
the DHTML-popup IS a solution ... and certainly the best one!
Jul 2 '08 #11
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
5,390 Expert Mod 4TB
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
16,027 Expert Mod 8TB
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.

Similar topics

6 posts views Thread by needin4mation | last post: by
10 posts views Thread by News | last post: by
3 posts views Thread by johkar | last post: by
9 posts views Thread by Alex D. | last post: by
8 posts views Thread by Clément | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.