Connecting Tech Pros Worldwide Help | Site Map

wait on button click

tshad
Guest
 
Posts: n/a
#1: Jun 27 '08
Is there an easy way to wait on a button click?

I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.

I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.

Thanks,

Tom


Ugo
Guest
 
Posts: n/a
#2: Jun 27 '08

re: wait on button click


Is there an easy way to wait on a button click?
Quote:
I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.
I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.
maybe, it's sufficient to use event handler "onclick", so:

<div id="layer"></div>
<input type="button"
value="hide"
onclick="document.getElementById('layer').style.vi sibility='hidden';"
/>
SAM
Guest
 
Posts: n/a
#3: Jun 27 '08

re: wait on button click


tshad a écrit :
Quote:
Is there an easy way to wait on a button click?
>
I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.
>
I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.
<html>
<script type="text/javascript">
function hidSho(id) {
var d = document.getElementById(id).style;
d.visibility = d.visibility==''? 'visible' : '';
}
function shoHid(id) {
var d = document.getElementById(id).style;
d.visibility = d.visibility==''? 'hidden' : '';
}
</script>
<style type="text/css">
#test { visibility: hidden; border: 1px solid }
</style>
<h2 id="test">here is the test 1</h2>
<p>pass mouse <a href="#"
onmouseover="hidSho('test');"
onmouseout="hidSho('test');"
onclick="return false;">over me</a></p>
<p><button onmousedown="hidSho('test');"
onmouseup="hidSho('test');">press me</button></p>

<h2 id="test2">here is the test 2</h2>
<p><button onmousedown="shoHid('test2');"
onmouseup="shoHid('test2');">press me</button></p>
</html>


--
sm
Closed Thread


Similar JavaScript / Ajax / DHTML bytes