views:

1080

answers:

4

I have the following JavaScript code to pop up a window in Internet Explorer. The code is executed from a page within a Microsoft CRM modal dialog box. (RequestID is a string that is always the same in the test system - at the moment it contains "abcdefg" - without the quotes).

var cancelUrl = "CancelRequest.aspx?RequestID=" + RequestID;
alert("About to open a window.\n\n" + cancelUrl);
window.open(cancelUrl);
alert("Window opened");

I expect to see a message telling me that I am about to open a window. I then expect to see a window open and get another message about the window having been opened. I don't really care about the order of the last two events; the alerts are there so I know the code has been executed.

I have two PCs and a virtual PC. All running IE7. On the Windows 2003 VPC, the messages and pop-up appear every time without fail.

On the Vista PC and WinXP PC, the messages appear but the pop-up only appears intermittently. (I think this may be the case on the Vista PC too).

All three have identical settings in IE. All have the IE pop-up blocker disabled and have no other pop-up blockers installed.

Can anyone shed any light on this?

A: 

What is in the RequestID? e.g. does it contain quotes or line breaks?

scunliffe
Just updated the question. It contains "abcdefg" - without the quotes
BlackWasp
re-read question and posted new answer below.
scunliffe
A: 

This code is simple. Use debugger and see what is going on.

Check that site with FireFox or Chrome, they have JS debuggers.

Edit:

Add try/catch block around window.open() and see if there is some exception there.

Edit 2:

I see now that you are sending characters as RequestId. You should check if that URL can handle that kind of value. Since name is RequestId I'd say that there is big chance that there should be numeric only parameter. If that is correct, then it can happen that server side crashes when you try to open window and then nothing happens. Reason more to set try/catch block and test.

zendar
Unfortunately I can't use these browsers because they don't work with Dynamics CRM (unless I am missing something).
BlackWasp
Used the Visual Studio 2008 debugger. The window.open call is made but nothing happens :-(
BlackWasp
Javascript or HTML is probably IE specific. Maybe you could try to run it in one of the browsers and navigate to page in question.
zendar
Another idea - add try/catch around that code. Put it into function and try to catch exception.
zendar
added try / catch - no error, no window
BlackWasp
A: 

You might want to try Firebug lite, which will work for IE.

http://getfirebug.com/lite.html

The try/catch other people have mentioned is also a good idea. I think.

Additionally, is there any chance that the pop-up is trying to use a window that is already open but minimized. So it doesn't appear to be working but it's really just reloading the minimized window?

Jack
+2  A: 

Ah, I think I got it... missed it in the description...

You are trying to open a non-modal window from a modal dialog in IE.

This AFAIK, should not work.

Try opening another modal window instead.

Effectively you are saying...

on window A, open up modal window B, now open up non-modal window C, which isn't really valid.

scunliffe