Jump to content

Modal Window


JORGEMAL
 Share

Recommended Posts

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

Edited by JORGEMAL
Link to comment
Share on other sites

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>

Edited by dsonesuk
Link to comment
Share on other sites

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

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

Edited by dsonesuk
Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...