www.webdeveloper.com
Results 1 to 2 of 2

Thread: onmousedown send GET request

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Location
    Oregon
    Posts
    144

    onmousedown send GET request

    Hello,

    I obviously don't know what terms to use when searching for this, so here is what I want to accomplish...

    I want to have a few buttons on a page, and each button has its own onmousedown and onmouseup functions. But what I want, is in those functions, for whatever necessary language to send a get request like this:

    Code:
    http://10.0.0.52/?up
    I have no idea what the correct syntax is for this. I also don't care what the response is for any of the requests. Here is an example that I worked up as far as I can...

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function up()
    {
    http://10.0.0.52/?up
    }
    
    function dn()
    {
    http://10.0.0.52/?dn
    }
    
    function lt()
    {
    http://10.0.0.52/?lt
    }
    
    function rt()
    {
    http://10.0.0.52/?rt
    }
    
    function stop()
    {
    http://10.0.0.52/?stop
    }
    </script>
    </head>
    <body>
    
    <h2>Control</h2>
    
    <table>
        <tr>
           <td width="50"></td>
           <td><button type="button" onmousedown="up()" onmouseup="stop()">Up</button></td>
           <td width="50"></td>
        </tr>
        <tr>
           <td><button type="button" onmousedown="lt()" onmouseup="stop()">Left</button></td>
           <td width="50"></td>
           <td><button type="button" onmousedown="rt()" onmouseup="stop()">Right</button></td>
        </tr>
        <tr>
           <td width="50"></td>
           <td><button type="button" onmousedown="dn()" onmouseup="stop()">Down</button></td>
           <td width="50"></td>
        </tr>
    </table>
     
    </body>
    </html>
    Any idea for where I can find this information would be great! Thank you.
    Jeremy

  2. #2
    Join Date
    Apr 2005
    Location
    Oregon
    Posts
    144
    OK, so I finally found out a way to do what I need. Here is what is working for me.

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function up()
    {
    document.feedback.location = "http://10.0.0.52/?up"; <!-- Where feedback is the name of my iFrame -->
    }
    
    function dn()
    {
    document.feedback.location = "http://10.0.0.52/?dn";
    }
    
    function lt()
    {
    document.feedback.location = "http://10.0.0.52/?lt";
    }
    
    function rt()
    {
    document.feedback.location = "http://10.0.0.52/?rt";
    }
    
    function stop()
    {
    document.feedback.location = "http://10.0.0.52/?stop";
    }
    </script>
    </head>
    <body>
    
    <h2>Control</h2>
    
    <iframe width="80" height="30" frameBorder="0" name="feedback" scrolling="no" src="http://10.0.0.52/?hello">
      <p>Your browser does not support iframes.</p>
    </iframe>
    
    <table>
        <tr>
           <td width="50"></td>
           <td><button type="button" onmousedown="up()" onmouseup="stop()">Up</button></td>
           <td width="50"></td>
        </tr>
        <tr>
           <td><button type="button" onmousedown="lt()" onmouseup="stop()">Left</button></td>
           <td width="50"></td>
           <td><button type="button" onmousedown="rt()" onmouseup="stop()">Right</button></td>
        </tr>
        <tr>
           <td width="50"></td>
           <td><button type="button" onmousedown="dn()" onmouseup="stop()">Down</button></td>
           <td width="50"></td>
        </tr>
    </table>
     
    </body>
    </html>
    Jeremy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles