being a geek isn't so bad
chicks still think i'm hot ;)

ShowModalDialog

Thursday, August 05, 2004 2:56 PM

So showmodaldialog has been a pain in my ass for the last few weeks, for various reasons. And before anyone says it, yes I know it only works in IE. Anyway, I've had 2 major (minor?) issues with it so far:

  1. If you have a button, or anything that fires an event in the modal dialog window, it opens up the page in a new browser. IE: if you pop up window.aspx using showmodaldialog and you click a button on window.aspx the event will open up a NEW browser window (not a modal dialog) and attempt to execute the command. Neat. So I found an easy fix, use , no now more extra window opening issue. OH! But wait, now that brings up a new issue!
    • If you are using and you move the modal dialog window to a different location on the screen than where it originally popped up, and then click a button, the modal dialog window moves back to where it originally popped! IE: if you pop the modal dialog window centered on the screen, then move it to the top left corner, when you click a button, it recenters itself. Not a huge deal, but it's annoying to have windows moving around on you. Solution: Use an iframe. Basically you have to create an iframe in a page (windowcontainer.aspx) and point the iframe to the page you want (window.aspx) and then use showmodaldialog to open windowcontainer.aspx.Viola! No more extra windows, no more windows moving around! I give it a week and I'll find some other retarded issue.

  2. The next issue is smaller, but just as annoying. When you use window.open to pop open a browser window, the height & width measurements are the height & width of the inner window (from the URL bar to the status bar). That doesn't seem to be the case for windows opened with showmodaldialog. When you use showmodaldialog, the theme you use in XP (Windows XP Style or Windows Classic Style) will change the inner window height (and maybe width, I haven't checked it really). I found this out while creating dialog windows for a project I am working on. I'm currently using the Windows Classic Style, and I was visually setting window heights, making sure there was about a 5 pixel space between the bottom of my browser window and the content of the window. Well my boss is using the Windows XP Style, and when he went to check out the windows, the content was being cut off. I attempted all kinds of work arounds but nothing works. Part of the problem is showmodaldialog windows don't use the same properties as normal windows, and most of the javascript that works on normal windows does nothing in a modal dialog. So my work around: Make the windows a little bit taller. It doesn't look quite as good in the Classic theme, but since most people use the XP theme, very few will notice.

I really wish there was a cross browser compatible solution comparable to showmodaldialog, but I haven't found anything. And before anyone points me to the hundreds of 'modal window' scripts, take these 'requirements' into account:

  1. The window needs to keep focus
  2. The window needs to close when the parent closes, or keep you from closing the parent.

Actually I guess there's just 2 'requirements' but showmodaldialog has a bunch of 'nice-to-haves' built in too, like no task bar presence, built in return value, no extra buttons on the title bar, etc.

Wish my luck with my fixes. Last thing I want to do is get everything programmed, then have to go back and recode it all.


Feedback

# Fun google tricks

8/19/2004 10:41 PM | being a geek isn't so bad

Post a comment





 

Please add 7 and 8 and type the answer here: