JavaScript - Opening Multiple Windows beside each other

I have an issue that has occurred with the upgrade to Windows SP2.

When I wrote the code originally, it worked fine. Now I get a Runtime Error when the Javascript attempts to open the 2nd window. The intent is to have two windows open beside each other. If I comment out one of the window open lines, the expected window does open. Problem only occurs when two windows are attempted.

Here’s the code:

function displayHelp(DocID)

{

// var h = window.screen.height;

var h = 700;

var w = window.screen.width;		



var date = window.document.forms[0].elements["Rating_Date"].value;

var rated = window.document.forms[0].elements["Employee_Name"].value;

window.open(window.location.pathname.slice(0, window.location.pathname.lastIndexOf(‘.ns’) + 5) + “GoalDialog?OpenForm&DimDocID=” + DocID + “&Rated=” + rated + “&Date=” + date, “Goal”, “MenuBar=no, left=” + (w/2 + 10) + “, top=0, width=” + (w/2 - 20) + “, height=” + h + “, ScrollBars=yes”);

window.open(window.location.pathname.slice(0, window.location.pathname.lastIndexOf(‘.ns’) + 5) + “DimensionDialog?OpenForm&ParentUNID=” + DocID, “Info”, “MenuBar=no, left=0, top=0, width=” + w/2 + “, height=” + h + “, ScrollBars=yes”).focus();

}

The runtime error occurs on the second window.open statement.

Can someone help please.

Thanks, Tom.

Subject: JavaScript - Opening Multiple Windows beside each other.

I’ve tried removing the ‘.focus()’ but that didn’t make a difference.

Also, I’ve swapped the two window.open statements around, and it’s always the second open that gets the runtime error.

Strangely too, I clicked the button on the main form twice, and both windows appeared, the first one with the first click of the button, the second window with the second click.

The issue seems to be not with the statements, but with having two window.open(s). Anyone know a workaround ?

Thanks, Tom

Subject: RE: JavaScript - Opening Multiple Windows beside each other.

I wonder if assigning the window to a variable will help (???):

var wOne = window.open(urlstr, ‘’, …

Subject: JavaScript - Opening Multiple Windows beside each other.

I agree. It sounds like a version issue. :slight_smile:

Try breaking it down to simpler pieces and debugging from there. Your code may be succinct and efficient, but it may be easier to debug if you build up one variable at a time, such as:

var urlstr = “…”;

var wOne = window.open(urlstr, ‘’, winFeatures);

…

var wTwo = window.open(urlstr, ‘’, winFeatures);

wTwo.Focus();

Guess … it could be the .Focus()

Subject: JavaScript - Opening Multiple Windows beside each other.

Can you do a window.open().focus()?

Thats a big difference between the two lines. Technically the function might return a window. But in the asynch world of browsers maybe it doesnt exist yet properly.

Simn