JORGEMAL Posted June 10, 2009 Share Posted June 10, 2009 I am developing a web application and I test it with several internet browsers: Microsoft IE8, Firefox, Opera and Chrome. In such an app there is a new window (I call it a child window) that opens in certain cases but if the user clicks somewhere on the parent window then the child window goes to the back. I am using the Focus() method to bring the child window back but I see that not all of the browsers support it like IE8. What I would like is to have the child window modal so it remains in the front until the user closes it using a button. Also, I need compatibility with the internet browsers mentioned above.Please advice.With respect,Jorge Maldonado Link to comment Share on other sites More sharing options...
dsonesuk Posted June 10, 2009 Share Posted June 10, 2009 I used this method ages ago, and it seems to work in all browsers.hang on..except Chrome Sorry!<body onfocus="trythis()"><script>function trythis(){if(strWinv) //checks if child window is already open{strWinv.focus(); //if yes focus on child window} }</script> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 10, 2009 Share Posted June 10, 2009 IE and Firefox 3 support opening modal windows with window.showModalDialog. Earlier versions of Firefox, and also Opera and Chrome, do not have a way to open a modal window. Link to comment Share on other sites More sharing options...
dsonesuk Posted June 10, 2009 Share Posted June 10, 2009 just checked this at http://javascript.about.com/library/blmodal.htm which supply an window.showModalDialog combined with window.open to cover different browsers. But Chrome does not open with either option, and Opera opens but when parent is clicked, it disappears behind parent.Where as the below code will open in all browsers, and stay in front, except for Chrome.function openenlargepic(s){ if(strWinv && !strWinv.closed) { alert("Close Opened Enlarged Image Window Before Continuing") strWinv.focus(); } else {strWinv=window.open("enlargepic.php?id="+s,"", "width=400,height=335, toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0"); strWinv.focus(); }}When used with:<body onfocus="trythis()"><script>function trythis(){if(strWinv) //checks if child window is already open{strWinv.focus(); //if yes focus on child window} }</script> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 10, 2009 Share Posted June 10, 2009 I understand what you're saying, that's just not a modal window. It tries to fake one, but it's not really the same thing. I just wanted to point out that only IE and Firefox 3 actually have support for real modal windows. Link to comment Share on other sites More sharing options...
rnd me Posted June 12, 2009 Share Posted June 12, 2009 chrome and safari both support showModalDialog.only opera is out... Link to comment Share on other sites More sharing options...
dsonesuk Posted June 12, 2009 Share Posted June 12, 2009 I understand, that the solution i suggested IS NOT a modal window, BUT since that, Yes IE, FF3 only support window.showModalDialog (not to sure about chrome as it didn't work for me) an alternative would be to use my solution, which seems to work in MOST browsers, instead of "oh well this window.showModalDialog does not work in all browsers, so you know what, lets just forget about it". The End Link to comment Share on other sites More sharing options...
justsomeguy Posted June 12, 2009 Share Posted June 12, 2009 instead of "oh well this window.showModalDialog does not work in all browsers, so you know what, lets just forget about it"I wasn't suggesting that Spunky, I was just trying to make sure the OP understood that only IE and Firefox 3 actually support truly modal windows. That was my only point, there's no reason to get upset. I haven't seen that modals work in WebKit browsers.I don't know if it's an option for you, but I prefer to use ExtJS for stuff like this:http://extjs.com/deploy/dev/examples/messa...ox/msg-box.htmlIt's using message boxes as an example, but you can open an Ext window and have it be modal, and have it contain any content. Again, it's not truly modal (for that matter, it's not a browser window either, it's a div), but they mask everything behind it so that you can't click on it (or so that clicking on it has no effect). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.