|
Posted by Jonathan N. Little on 02/26/07 14:28
Andrew Bailey wrote:
> "Ben C" <spamspam@spam.eggs> wrote in message
> news:slrneu3cr6.ffc.spamspam@bowser.marioworld...
>> On 2007-02-25, Chris <nospam@btinternet.com> wrote:
>>> Not sure if this is the right place to post. Can anyone tell me how to
>>> disable a button until the page is fully loaded. Regards, Chris.
>> There is an "onload" event for the DOM document, but don't ask me the
>> rules determining precisely when it occurs.
>
> Hi,
>
> Try this....
>
> <script>
> function activatebutton(){
> buttonoff.style.display='none';
> buttonon.style.display='inline';
> }
> </script>
>
> <body onload="activatebutton()">
>
> <div id="buttonoff" style="display: inline">
> <img src="../images/buttonimg.gif">
> </div>
>
> <div id="buttonon" style="display: none">
> <a onclick="dosomething()"><img src="../images/buttonimg.gif"></a>
> </div>
>
> </body>
>
> Hope this helps
And if they have JavaScript disabled the function would be better
described as donothing()!
Far better to to use JavaScript as a precheck...have a variable that is
initially set as false, then attach to onload event to reset to true.
Trap the submit of form to check if variable is true or not to allow or
cancel the submit action. But you should *always* do a final check of
all submitted data server-side with receiving script. With this method
if JavaScript is disable the form will still submit, but the server-side
script will catch the missing data error.
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
[Back to original message]
|