Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.close() focus problem 1

Status
Not open for further replies.

audiopro

Programmer
Joined
Apr 1, 2004
Messages
3,165
Location
GB
I have an HTML form which contains several animated Gif's.
There is a link on the form which launches a contact form within a new window using window.open() - this works ok and the resulting form can be completed is submitted to a PERL script, which generates a reply within the child form. Then
I close the form with a button set up to run function - window.close(). Window closes and shows original calling window but now the animations are frozen and attempting to run the window.open() function results in the following error.

Code:
Line: 1
Char: 1
Error: The callee(not server application) is not available and disappeared; all connections are invalid. The call did not execute.
Code: 0
URL: [URL unfurl="true"]http://.............................[/URL]
It would appear that the focus is not being passed back to the calling window but I have seen no mention of having to set the focus.
What am I missing?

Keith
 
The popup window contains a contact form which is completed and submitted. This returns a thankyou for filling in the form message and a close button.
There is no interaction between the two forms as the link carries the info to the PERL script.
I designed it this way to prevent the user having multiple windows open.

Keith
 
Can you give a URL to the page in question? If there's absolutely no interaction from the child (popup) window to the parent (opener) window, I don't see why you should get this simply when closing the popup.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It may be a validation issue as the validator just throws it back at me with a whole bunch of unhelpful error messages.
I am off for a crash course on what is allowed in HTML this week.


Keith
 
I have validated the page but the error still remains.
So back to basics
I have set up the following test page on a test server and the error is still present.
Clicking the first link opens the new window as expected.
Close the new window and click the link again and I get an error.


I have tried it on 3 servers and get consistent results.
It has to be the code but can anyone suggest a cure?

Keith
 
Ah! Here is a problem... you are redefining the function into a variable (in the demo pages you show):
Code:
function Contact(cont) {
Contact=window.open(cont,'contWin','height=700 width=550 scrollbars=yes resizable=no close=yes')
Contact.focus();
}
This would be how to change it to work without replacing the function:
Code:
function Contact(cont) {
Contact[b]Win[/b]=window.open(cont,'contWin','height=700 width=550 scrollbars=yes resizable=no close=yes')
Contact[b]Win[/b].focus();
}
Basically I am changing the variable you use so that it doesn't match the function name.

Maybe you are doing something similar on your main code? I hope so... since that would solve it for you.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Thanks Jeff
I have been staring at that and not registering anything.
If I understand the function, 'Contact' is the function name wheras 'ContactWin' is the name of the created window.
I always thought that the additional lines just defined what the function does.
The mist is clearing now, thanks once again.

Keith
 
Contact is the name of the function.
ContactWin is the name of the handle to that window (allowing you to set it's focus etc).
ContWin is the name you have given the window itself.

Three different things... all actoing together to confuse even the most wary of developers [smile]

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
I still have the same problem with my animated Gif's freezing on return to the calling screen although the page no longer shows an error.

Function declared in the head section of the form.
Code:
function Contact(cont) {
ContactWin=window.open(cont,'contWin','height=600 width=550 fullscreen=yes scrollbars=no resizable=no close=yes')
ContactWin.focus();
}

Link to open the new window.
Not strictly java as it is called from within a perl script but it does the call and subsequent close without complaining.
Code:
	$LINK[8]="javascript:Contact('contact.cgi?call=contus&disp=49&formed=49')";
window closed using
Code:
<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>
The page works ok if it is refreshed but appears not to have the focus, on it's return from the called proc.
Do I need to name the window which is to be closed?

Keith
 
I am still experiencing this problem.
Can anyone suggest a cure?
The returned page works ok but animated gifs are frozen.
Refreshing the page restores all the functions

Keith
 
Give this a whirl...

Instead of calling the contact function via an anchor:

Code:
<a href="javascript:Contact(...);">...</a>

try calling it from a non-anchor:

Code:
<span style="cursor:pointer;" onclick="Contact(...);">...</span>

Just one of the wild theories, but you never know ;-)

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top