Help with opening a window in Netscape

T

The Athiest

Hi,

I have the following JavaScript function which works fine in IE, Opera and
Firefox. I can't get it to work in Netscape 7.2

Here is the code:

/**************************************************/
/* Display a popup window centered on the screen. */
/* Width and Height are supplied by the caller. * /
/**************************************************/
var win= null;
function newWindow(mypage,myname,w,h,scroll) {
var winl = (screen.availWidth-w)/2;
var wint = (screen.availHeight-h)/2;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars='+scroll+',';
settings +='resizable=yes';
win=window.open(mypage,myname,settings);
if (parseInt(navigator.appVersion) >= 4) {
win.focus();
}
if (!win.opener) {
win.opener = self;
}

return win;
}

1. I get the following error when I click on a link which attempts to open
the window:
"win has no properties"

2. When I comment out the two if statements at the bottom of the function, I
do not get an error but nothing happens (no window).

Any ideas?

Thanks,
Don
 
L

Lee

The Athiest said:
Hi,

I have the following JavaScript function which works fine in IE, Opera and
Firefox. I can't get it to work in Netscape 7.2


1. I get the following error when I click on a link which attempts to open
the window:
"win has no properties"


When I copy that code to a page and call it with the following button,
it works just fine in Netscape 7.2. What are you doing differently?

<button
onclick="newWindow('http://www.google.com','gwin',600,400,1)">Google</button>
 
I

Ian Sedwell

Hi Dan

Try something like this... I had a similar problem, but not with N7.2... DU
very kindly helped out and my solution is based on the pointers he gave me.
It works for me!

var flightDetailsWindow = null;

function displayFlightDetails () {
var theURL = "framedetail.htm";
var pageName = "flightdetail.htm";
var winName = "Flight_Detail";
var winHeight = 500;
var features = "scrollbars=no,";

if (screen.height <= 480) {
features += "scrollbars=yes,";
winHeight = screen.height - 100;
}

features += "toolbar=no,";
features += "menuBar=no,";
features += "directories=no,";
features += "status=no,";
features += "resizable=no,";
features += "width=500,";
features += "height=" + winHeight + ",";
features += "left=30,";
features += "top=30";

flightDetailsWindow =
openDisplayWindow(flightDetailsWindow,theURL,winName,features);

writeDetailsContent(flightDetailsWindow,winName,pageName);
}

function openDisplayWindow (windowRef,contentURL,windowName,features) {
if ((windowRef == null) || (windowRef.closed)) {
windowRef = window.open(contentURL,windowName,features);
}
else {
windowRef.focus();
}

return windowRef;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,297
Latest member
EngineerD

Latest Threads

Top