469,640 Members | 1,561 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,640 developers. It's quick & easy.

Can someone help e debug this popup window script please?

Don
Hi,

I have the following script that displays a popup window centered in the
middle of the screen. I am getting a script error in both IE and Netscape
but I don't know what it means. Thanks in advance.

The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); )

The code is
------------
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.window.focus();
if (!win.opener)
win.opener = self;
}
Jul 20 '05 #1
6 1502
Don wrote:
Hi,

I have the following script that displays a popup window centered in the
middle of the screen. I am getting a script error in both IE and Netscape
but I don't know what it means. Thanks in advance.

The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); ) I'm no specialist but the win.window.focus() seems rather odd (to me).
Why not win.focus() (y'v got the variable).
Otherwise I'd set a breakpoint below win=... to see what has happened.

F DCG
The code is
------------
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.window.focus();
if (!win.opener)
win.opener = self;
}

Jul 20 '05 #2
In article <o4*******************@news01.bloor.is.net.cable.r ogers.com>,
do********@rogers.com enlightened us with...
Hi,

I have the following script that displays a popup window centered in the
middle of the screen. I am getting a script error in both IE and Netscape
but I don't know what it means. Thanks in advance.

The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); )
win is a window object. There is no window property of a window object,
AFAIK.
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4)
win.window.focus();


win.focus() or win.document.focus()
--
--
~kaeli~
A little rudeness and disrespect can elevate a meaningless
interaction to a battle of wills and add drama to an
otherwise dull day.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3
In article <o4*******************@news01.bloor.is.net.cable.r ogers.com>,
do********@rogers.com enlightened us with...

The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); )
Also, you don't check for null before you try
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4) {
if (win != null)
win.focus();
else alert("no window object");
}
if (!win.opener)
win.opener = self;
}


That would cause problems with popup blockers that killed the window.

--
--
~kaeli~
A little rudeness and disrespect can elevate a meaningless
interaction to a battle of wills and add drama to an
otherwise dull day.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4
DU
Don wrote:
Hi,

I have the following script that displays a popup window centered in the
middle of the screen. I am getting a script error in both IE and Netscape
but I don't know what it means. Thanks in advance.

The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); )

This message might refer to an asynchronuous state of the window and its
object reference. The win variable might not be created in the stack
while you're trying to access its properties.
The code is
------------
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';
Scrollbars should be set to true (or 1) at all the time: scrollbar(s)
should appear when content overflows requested window dimensions,
otherwise the popup goes against normal and standard accessibility to
content.
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4)
win.window.focus();
There is no point to this instruction. You are supposed to just have
created and opened a new window which will be brought on top of the
opener. Why try to bring it on top? This is redundant and unneeded.
if (!win.opener)
win.opener = self;


This instruction too should be dropped. It can only lead to problems.

DU
Jul 20 '05 #5
DU
kaeli wrote:


The error is
------------
Error: win has no properties
Line 13 below ( win.window.focus(); )

win is a window object. There is no window property of a window object,
AFAIK.


"The window property is a synonym for the current window or frame.
Property of window
Read-only (...)"
http://devedge.netscape.com/library/...w.html#1204007

DU
Jul 20 '05 #6
In article <bu**********@news.eusc.inter.net>,
dr*******@hotWIPETHISmail.com enlightened us with...

"The window property is a synonym for the current window or frame.
Property of window
Read-only (...)"
http://devedge.netscape.com/library/...w.html#1204007


Good to know.

Thanks!
--
--
~kaeli~
Dijon vu - the same mustard as before.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

38 posts views Thread by Shaun McKinnon | last post: by
1 post views Thread by Robert | last post: by
12 posts views Thread by HarveyB | last post: by
26 posts views Thread by Raffi | last post: by
4 posts views Thread by VR | last post: by
2 posts views Thread by jackson2005 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.