[Javascript] [OT ]popup window close

smitha.ramaswamy at wipro.com smitha.ramaswamy at wipro.com
Thu May 13 11:48:14 CDT 2004


Hello,

Could you please remove my email id from the mailing list...I think this
id was included accidentally.

Could you kindly do this at the earliest as I am getting all these mails
to my office id?

Thanks in advance.

Regds,
Smitha

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Nick Fitzsimons
Sent: Thursday, May 13, 2004 10:06 PM
To: [JavaScript List]
Subject: Re: [Javascript] [OT ]popup window close


On 13/5/04 4:57 pm, "Paul McGuire" <pmcguire at cguk.co.uk> wrote:

> Its actually reporting on a database... so the query is expected to 
> take a while. I just need a courtesy message so people dont think its 
> crashed.
> 

Non-pop-up DHTML method:

Have the page in two parts: one with the form, one with the "Please
stare vacantly at the animated GIF" message. Use CSS to show the first
part and hide the second:

    <!-- 
        this is visible when the punter first comes to the page
    -->
    <div style="display: block;" id="formContainer">
        <form...
        .../form>
    </div>

    <!-- 
        This is initially invisible, but will become visible
        when they submit the form
    -->
    <div style="display: none;" id="messageContainer">
        <h1>Please stare vacantly...</h1>
        <img src="prettyAnimation.gif" />
    </div>

Then for the onsubmit handler:

    <form action="submit.htm" onsubmit="return submitHandler();">

And finally the JavaScript function:

function submitHandler() {
    document.getElementById("formContainer").style.display = "none";
    document.getElementById("messageContainer").style.display = "block";
    return true;
}

Note that if you want to support IE4/Win, you'll need to use
document.all["formContainer"] instead of getElementById. Check out the
usual sources of info on object detection and browser sniffing for
details.

The end result is that, if the form is to be submitted, the block of
HTML containing the form is hidden by modifying its style, and in its
place the message is displayed. This has the advantage that the punter
can't keep clicking "Submit". Then "true" is returned to the onsubmit
handler, which in turn returns that value, which allows the form
submission to proceed.

And the animated GIF? That just makes them think something is happening
:-)

(If you need to support Netscape/IE version 3, you can produce a similar
effect through a wild and wonderful technique I developed several years
ago, but the margins of this email are too small to contain it.)

HTH,

Nick Fitzsimons.
-- 
Nick Fitzsimons
nick at nickfitz.co.uk


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list