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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does my pop up window not wait for a close?

Status
Not open for further replies.

zombee

Programmer
May 16, 2008
18
US
I've got a button, when clicked,
will show a pop-up screen.

Get to this window via
var w=window.open ("","newW","height=260,width=350, status=0");

Just to first keep it simple, this new window contains only 1 button
var d = w.document;
d.write('<FORM>');
d.write('<INPUT TYPE="submit" VALUE = "Quit" onClick="self.close()">');
d.write('</FORM>');


The code in fact pops up the new window - but why does it continue without waiting for the Quit button to close it?
 
But something just doesn't figure.
Why would javascript give me the ability to pop open a new screen,
yet disable me from using it?
 
I don't get the last question. I guess you get the window and then you can click the button ...

Cheers,
Dian
 
To clarify -

I need to open a window to display some
historical data I've captured during a browser
session. I want to create a button for the user
to view this data.
The button, "View Data Captured", then will open
this new window, to allow the user to view the data.

The problem I'm having is that the window disappears from
view as soon as it comes up. I'm doing something wrong
in that the Quit button of the new window is presently ignored.
 
Try using "d.open();" and "d.close();" before and after you write your content.

Also, try writing well-formed HTML into the popup - at present, you're missing many key elements (HTML, BODY, etc).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Your code works for me.

How are you including the script in your main window? Any pop-up blocker around?

Cheers,
Dian
 
My original intention was to hide from view some buttons on my parent window,then pop-up a new, child window,
then redisplay the parent's buttons.

But I had problems with the code that came AFTER I gave focus to the child
window. The parent window buttons should have redisplayed AFTER the user hit the child window's Submit button.
Instead, the code did not wait for the submit event; It prematurely redisplayed the buttons.
The Submit button did close the child window but, in effect, did nothing to trigger the redisplay of buttons,
which took place well before this button was hit.

I tried to "spin my wheels" with "WHILE (child.window not closed)" logic,
trying to force the code to wait for the submit to take effect, but I couldn't.

It's tricky. Window.close flushes out the code to the document, but if that document is really closed - I was never sure.
The onClick=self.close() worked to close but not to hold the subsequent code from processing.
I tried adding to self.close() a global variable assignment ("...;g_var = 1") but that too did not control my code.
This level of js expertise is beyond me.

Because I could not control the timing of the "runaway" code to control my main screen's presentation,
I decided to try a new avenue - to use ajax and an HTML window's form.
Hope that works out for me. Although I've never yet brought up a child window's form in that way, but I'll give it a try.

I thank you all for your time and input.
 
I think I'm wasting your time because I'm confused.
I use javascript to store values in an array during the user session.
I need to display these data at some point for the user to pick one of them.
It's only then that I need to access the server.
So going the ajax route to present the user with javascript data
makes no sense at all.

I have to rethink my strategy anew.
And I need to break the problem into smaller, more coherent parts
before I present them.

Cheers!
 
When you do figure it out, if you need help with more problems, perhaps phrasing the questions to make sense would be a good idea.

Your original and follow up posts contained no information to diagnose what turned out to be your real problem.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan - You're right.
I'll start a new thread, correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top