wait on button click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    #1

    wait on button click

    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

    #2
    Re: wait on button click

    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.
    maybe, it's sufficient to use event handler "onclick", so:

    <div id="layer"></div>
    <input type="button"
    value="hide"
    onclick="docume nt.getElementBy Id('layer').sty le.visibility=' hidden';"
    />

    Comment

    • SAM

      #3
      Re: wait on button click

      tshad a écrit :
      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.getEle mentById(id).st yle;
      d.visibility = d.visibility==' '? 'visible' : '';
      }
      function shoHid(id) {
      var d = document.getEle mentById(id).st yle;
      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="hi dSho('test');"
      onmouseout="hid Sho('test');"
      onclick="return false;">over me</a></p>
      <p><button onmousedown="hi dSho('test');"
      onmouseup="hidS ho('test');">pr ess me</button></p>

      <h2 id="test2">her e is the test 2</h2>
      <p><button onmousedown="sh oHid('test2');"
      onmouseup="shoH id('test2');">p ress me</button></p>
      </html>


      --
      sm

      Comment

      Working...