HighDots Forums  

Waiting for a window to close -- without killing the CPU

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Waiting for a window to close -- without killing the CPU in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Charles Lavin
 
Posts: n/a

Default Waiting for a window to close -- without killing the CPU - 08-07-2009 , 09:18 PM






Hi --

I have a Web page. When a user clicks on a link on this page, I need a
pop-up window to open; that window will execute server-side code. When this
window is closed (and not before), I need the main page to reload.

I coded this for the link, which works:

<a onclick="w = window.open('whatever'); while (!(w.closed));
location.reload(); return false;" href="whatever">CLICK HERE</a>

The user clicks on the link on the main page, does what he needs to do on
the pop-up window, closes that pop-up window, and the main page
automatically reloads.

However, I have noticed that when that pop-up window opens, the process
associated with the main window chews up all of the available CPU. I suspect
it's that while statement spinning in place with nothing to do.

Is there a cleaner way to do what I need to do, or at least one that won't
chew up the CPU?

Is there a way for that pop-up window to force a reload of the main page
before it closes?

Thanks,
CL

Reply With Quote
  #2  
Old   
Andy
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-08-2009 , 04:24 AM






"Charles Lavin" <x@x.x> wrote

Quote:
Hi --

I have a Web page. When a user clicks on a link on this page, I need a
pop-up window to open; that window will execute server-side code. When
this window is closed (and not before), I need the main page to reload.

I coded this for the link, which works:

a onclick="w = window.open('whatever'); while (!(w.closed));
location.reload(); return false;" href="whatever">CLICK HERE</a

The user clicks on the link on the main page, does what he needs to do on
the pop-up window, closes that pop-up window, and the main page
automatically reloads.

However, I have noticed that when that pop-up window opens, the process
associated with the main window chews up all of the available CPU. I
suspect it's that while statement spinning in place with nothing to do.

Is there a cleaner way to do what I need to do, or at least one that won't
chew up the CPU?

Is there a way for that pop-up window to force a reload of the main page
before it closes?

Thanks,
CL


Hi Charles,

Haven't got time to give you a full in-depth answer as I've got to go out,
but if you visit my site...

www.microbuild.com

and click the image to the right of the Microbuild title (initially "Under
Construction" then text alerts, then tour) it will start the site tour (i.e.
will launch the popup).

You have to go at least one step into the tour before the code is used. Now
you can examine the source to get the idea. Basically, if the user clicks
any button that continues the tour, the code in question does nothing, but
if the user closes the tour popup or reaches the end then it loads a thank
you page into the main/original content frame.

The technique allows you to control the original content from the popup,
even run scripts etc.

You should get the gist if not I'll help when I'm back.


Andy

Reply With Quote
  #3  
Old   
dorayme
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-08-2009 , 07:25 PM



In article <pDafm.179997$l73.133824 (AT) newsfe11 (DOT) ams2>,
"Andy" <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:

Quote:
"Charles Lavin" <x@x.x> wrote in message
news:On4fm.96762$9P.6895 (AT) newsfe08 (DOT) iad...
Hi --

I have a Web page. When a user clicks on a link on this page, I need a
pop-up window to open; that window will execute server-side code. When
this window is closed (and not before), I need the main page to reload.

.....

Hi Charles,

Haven't got time to give you a full in-depth answer as I've got to go out,
but if you visit my site...

www.microbuild.com
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Reply With Quote
  #4  
Old   
Andy
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 03:34 AM



Quote:
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme
Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every site
he visits despite having perfectly good eyesight just so that he can
criticize. Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text. As an ex
hallway monitor, he has a penchant for rule breaking and believes that only
sites that pass strict validation are worth looking at despite the fact that
none of the top sites in the world pass and that the validation tool often
gives false results.


Andy

Reply With Quote
  #5  
Old   
Ben C
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 03:52 AM



On 2009-08-11, Andy <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:
Quote:
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every site
he visits despite having perfectly good eyesight just so that he can
criticize. Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text. As an ex
hallway monitor, he has a penchant for rule breaking and believes that only
sites that pass strict validation are worth looking at despite the fact that
none of the top sites in the world pass and that the validation tool often
gives false results.
Do you have an example of the validation tool giving false results? I
don't mean bogus warnings (they are to be expected).

Reply With Quote
  #6  
Old   
dorayme
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 04:09 AM



In article <6a9gm.88611$Cj1.33551 (AT) newsfe30 (DOT) ams2>,
"Andy" <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:

Quote:
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every site
he visits despite having perfectly good eyesight just so that he can
criticize.
Hello, hello, hello! What have we here? I am being criticized for being
concerned that website makers take account of people with even
*slightly* different eyesight to me?

Quote:
Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text.
It is a sign of false eyesight not to want pics zoomed or to use
browsers that do not do general zooming? Or, much more to the point, to
draw attention to the good practice of not assuming that everyone zooms
the same way?

Quote:
As an ex
hallway monitor, he has a penchant for rule breaking and believes that only
sites that pass strict validation are worth looking at
Your evidence for this? My evidence says most sites I look at do not
pass validation and some are pretty good anyway...

You are very familiar with me young man!

--
dorayme

Reply With Quote
  #7  
Old   
Andy
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 05:04 AM



"Ben C" <spamspam (AT) spam (DOT) eggs> wrote

Quote:
On 2009-08-11, Andy <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every
site
he visits despite having perfectly good eyesight just so that he can
criticize. Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text. As an ex
hallway monitor, he has a penchant for rule breaking and believes that
only
sites that pass strict validation are worth looking at despite the fact
that
none of the top sites in the world pass and that the validation tool
often
gives false results.

Do you have an example of the validation tool giving false results? I
don't mean bogus warnings (they are to be expected).
Sure...

http://validator.w3.org/check?uri=www.microbuild.com&charset=%28detect+aut omatically%29&doctype=Inline&group=0

Gives 2 warnings and 69 errors. Now start to read the errors and you'll soon
realise that that the validator is complaining that I have used capitals
(not exactly crime of the century is it?). Now go visit www.microbuild.com
and check the source... guess what? I don't use capitals at all.


Andy


Anyhoo, let's not get off topic (I know some people revel in dragging out
differences of opinion). Regardless of my coding style etc, there is a
solution to the OP question which I think works quite well.

Reply With Quote
  #8  
Old   
Andy
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 05:07 AM



"Andy" <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote

Quote:
"Ben C" <spamspam (AT) spam (DOT) eggs> wrote in message
news:slrnh828lg.3hf.spamspam (AT) bowser (DOT) marioworld...
On 2009-08-11, Andy <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:
Being how this is posted to alt.html, be careful of using this site as
a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every
site
he visits despite having perfectly good eyesight just so that he can
criticize. Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text. As an ex
hallway monitor, he has a penchant for rule breaking and believes that
only
sites that pass strict validation are worth looking at despite the fact
that
none of the top sites in the world pass and that the validation tool
often
gives false results.

Do you have an example of the validation tool giving false results? I
don't mean bogus warnings (they are to be expected).

Sure...

http://validator.w3.org/check?uri=www.microbuild.com&charset=%28detect+aut omatically%29&doctype=Inline&group=0

Gives 2 warnings and 69 errors. Now start to read the errors and you'll
soon realise that that the validator is complaining that I have used
capitals (not exactly crime of the century is it?). Now go visit
www.microbuild.com and check the source... guess what? I don't use
capitals at all.


Andy


Anyhoo, let's not get off topic (I know some people revel in dragging out
differences of opinion). Regardless of my coding style etc, there is a
solution to the OP question which I think works quite well.
Phooey! I have got some capitals in there... but not all the ones that the
validator complains about.

Reply With Quote
  #9  
Old   
Ben C
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 06:18 AM



On 2009-08-11, Andy <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:
Quote:
"Ben C" <spamspam (AT) spam (DOT) eggs> wrote in message
news:slrnh828lg.3hf.spamspam (AT) bowser (DOT) marioworld...
On 2009-08-11, Andy <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:
Being how this is posted to alt.html, be careful of using this site as a
model for general markup or design or CSS, the author seems unaware of
fundamental usability issues. Apart for errors in validation, see what
happens when user uses a text size that the author never anticipated
even though the trouble starts at just one click up in "text only"
enlargement.

--
dorayme

Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every
site
he visits despite having perfectly good eyesight just so that he can
criticize. Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text. As an ex
hallway monitor, he has a penchant for rule breaking and believes that
only
sites that pass strict validation are worth looking at despite the fact
that
none of the top sites in the world pass and that the validation tool
often
gives false results.

Do you have an example of the validation tool giving false results? I
don't mean bogus warnings (they are to be expected).

Sure...

http://validator.w3.org/check?uri=www.microbuild.com&charset=%28detect+aut omatically%29&doctype=Inline&group=0

Gives 2 warnings and 69 errors. Now start to read the errors and you'll soon
realise that that the validator is complaining that I have used capitals
(not exactly crime of the century is it?). Now go visit www.microbuild.com
and check the source... guess what? I don't use capitals at all.
It is an error-- link doesn't have a name (or NAME) attribute in the
type of document you're using.

Suggesting 'did you mean "name"?' is utterly brain-dead, even for a
computer, because as you say you typed name and not NAME anyway.

But it _is_ still an error, and in that sense it's not a false result.

And there are good practical reasons not to use bogus attributes
everywhere like hidefocus, height on tables, align=absmiddle etc.-- they
might be supported in browsers you tested but are less likely to be
supported in ones you didn't test or that don't exist yet than if you
stick to the specs.

Their behaviour is also not specified anywhere so people writing new
browsers and trying to support all this non-standard stuff to make lousy
sites like microbuild.com work just have to guess what all these things
are supposed to do by trial and error with existing browsers.

Reply With Quote
  #10  
Old   
AT
 
Posts: n/a

Default Re: Waiting for a window to close -- without killing the CPU - 08-11-2009 , 07:49 AM



In article <6a9gm.88611$Cj1.33551 (AT) newsfe30 (DOT) ams2>, "Andy" <andy (AT) REMOVETOEMAILmanyplay (DOT) com> wrote:

Quote:
Seeing as this is posted to alt.html, be careful when taking this guy's
advice as he has an irresistible urge to change the text size of every site
he visits despite having perfectly good eyesight just so that he can
criticize.
You're evidently fairly young. Not everyone who looks at your site is. I'm 51,
and wear bifocals -- and some of the text on your site is difficult for me to
read unless I zoom the browser a bit.

Quote:
Why he doesn't use the zoom function is a mystery and one can
only assume that his false eyesight issue only affects text.
I imagine that he does use it -- but I also imagine that he's not using
Internet Explorer, which apparently is the *only* browser in which you've
*ever* tested the site. In both Firefox 3 and Safari, your layout problems
become apparent with a single zoom step (press Ctrl-plus) -- and in Opera, the
problems are glaringly obvious, even *without* zooming, as soon as the page
finishes loading.

Speaking of which... why does that page take so damn long to load? Have you
ever actually visited the site, or do you do all your testing using Apache or
IIS locally?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.