Forum Moderators: open

Message Too Old, No Replies

blur and focus problem

         

richard au13

10:32 am on Feb 12, 2004 (gmt 0)

10+ Year Member



Hello list, my first post and my first attempt at writing javascript.
This works in IE, to a point, and partly works in Netscape so I'm wondering how I fix the code to run in both browsers,that is if in fact it is correctly written.

I have this on the page that creates the new window (named 'noteTaker').Its fired from a button in a flash swf

<!--
function onTop(theURL,winName,features){
var theWin = window.noteTaker
alert(theWin)
// undefined before the window is opened
// object after the window is created
if (theWin == null ){
noteTaker=window.open(theURL,winName,features);noteTaker.focus();

} else {
window.noteTaker.focus()

}

}
//-->

This works opens the window and once open focuses the window if blured in IE but refreshes the window in Netscape (don't want this to happen).
Also after the popup is created and is closed manually the alert returns object not undefined
Any hints would be appreciated.

Regards

Richard

korkus2000

4:18 pm on Feb 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why is the alert firing when you close your window? Which version of netscape is causing the problems? Have you tried it in mozilla?

richard au13

5:03 am on Feb 16, 2004 (gmt 0)

10+ Year Member



Hi Korkus2000

Sorry, after reading my post it does seem like the alert fires when the created window closes. That is not the case. It is after I manually close the created window and then try to open it again using the function that the alert returns the variable as "object" and therefore does not open the window in any browser. I think this is because the var is not null so the function goes looking for the created window to focus but it's not available. I just don't know how to kill the variable or return it to undefined if the created window is closed. If I refresh the parent window the var returns to undefined.

The browsers I'm testing on are Netscape 7.1 and FireBird 1.5. the function opens the window in both but I can't get the created window to blur using this code in the created windows page
function minimizeBrWindow() {
this.window.blur();
}
Again this is fine in IE

Thanks for any help or hints

Richard

richard au13

3:34 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



Problem solved thanks to the archives

Solutions (probably should read work arounds :-) )
1: problem with manually closing the popup and not being able to open it again.
S: from a post in June 2003 by korkus2000
>You can do a refresh from a window opened by that >document.
>window.opener.history.go(0);
>window.close();

>thus should refresh the parent window.

I put this in a function on the pop up page and called it via <body onUnload > .The opener page refreshes and returns the var to undefined

2:popup won't blur() in Netscape or Mozilla
S:From a button on the popup page
window.opener.focus()