HtmlPage.PopupWindow is flawed in IE

Or at least in IE 8. I haven’t been able to try this in IE 7 or even the dreaded IE 6, but it is flawed in my browser. If you try opening a new window by calling HtmlPage.PopupWindow and try to have it resizable it does not make it resizable. (BTW, Silverlight calls the property Resizeable, while Live Writer tells me it should be spelled Resizable…hmm…I’m Swedish, but that gives me mixed signals…)

The code is actually quite simple, and it works in FireFox.

HtmlPopupWindowOptions opts = new HtmlPopupWindowOptions();
opts.Width = (int)Size.Width;
opts.Height = (int)Size.Height;
opts.Resizeable = true;
opts.Menubar = false;
opts.Scrollbars = false;
opts.Directories = false;
opts.Location = false;

HtmlWindow win = HtmlPage.PopupWindow(Url, TargetName, opts);


The reason? Well…I checked using JavaScript, since I guess that this call actually falls back to this or uses the same API. In JavaScript, passing the window parameter “resizable=true” does not work in IE. It works in FireFox though. However, If I change it to “resizable=1” it works in both…wonder if Microsoft missed this and basically just use ToString() on the properties…hmm…Reflector…here I come!

No, Microsoft does not do it quite as I thought the would. They actually convert the bool to “Yes” or “No”, which is sort of weird, cause using “Yes” in JavaScript works in both browsers… Hmm…due to this, I have no explanation anymore…

However, I found some interesting things in the HtmlpopupWindowOptions class. It seems to limit the size of the window you open to be maximum current windows size –250 pixels…

I also found a property that we should all use when we open windows. HtmlPage.IsPopupWindowAllowed will tell you if a pop-up blocker will block you when open windows. This is a great property to check and notify the user if pop-ups are not allowed. We probably should have done this on the Office 2010 Backstage site… Especially since Safari just swallows the window and doesn’t even notify the user… I don’t know if it always does it like that or if it is only when our designer Dave is using it…

Comments (2) -

I've tried my luck with reflector as well.
What I've noticed there was, that there's a line within HtmlPopupWindowOptions.ToFeaturesString() that reads

Maybe the problem is not with the value ("yes", "no") but with the key ("resizeable", where everyone else uses "resizable").

JasonBSteele 7/22/2010 12:53:08 PM

Yep, it's broken. I'm using

System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank", "toolbar=0,menubar=0,resizable=1,scrollbars=1");


Comments are closed