User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,036 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1061 | Replies: 6
Reply
Join Date: Jul 2006
Location: Oblivion
Posts: 647
Reputation: jaepi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
jaepi's Avatar
jaepi jaepi is offline Offline
Practically a Master Poster

script/function to lock a mouse and keyboard.

  #1  
Apr 9th, 2008
Hello there, is it possible for javascript to lock a mouse when you click on a button or a div? I was doing some google search but I failed to find a script for locking a keyboard or mouse. I just would want to add this feature on my site. Thanks!
Retreat!!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 5
Solved Threads: 46
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: script/function to lock a mouse and keyboard.

  #2  
Apr 9th, 2008
No. No sane browser / OS setup will let a webpage 'lock the keyboard or mouse'. Think for 30 seconds why this is the case.

If you want to disable all interaction with your site when the user clicks something.. oh-k, something like document.body.disabled = true/false; should suffice, although I can't see why you'd want to do this.

The other case, actually locking the keyboard or mouse system-wide; no chance. Even some application programming languages ( non-web ) wont let you do this. I'm sure your individual motives are good, but that's far from the point.

Maybe throw a little popup window that says 'please unplug your peripherals'... O_o
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Jul 2006
Location: Oblivion
Posts: 647
Reputation: jaepi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
jaepi's Avatar
jaepi jaepi is offline Offline
Practically a Master Poster

Re: script/function to lock a mouse and keyboard.

  #3  
Apr 9th, 2008
I saw something like that before, when you click on a div it locks the mouse and when you click it back, it unlocks it, but i forgot the site and i forgot to copy the script and that was in javascript. *sigh*
Retreat!!!
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 5
Solved Threads: 46
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: script/function to lock a mouse and keyboard.

  #4  
Apr 10th, 2008
If the mouse is locked, how do you click again to unlock it?

What do you mean exactly by 'locked'? I took that to mean disabled/no longer functional.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Jul 2006
Location: Oblivion
Posts: 647
Reputation: jaepi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
jaepi's Avatar
jaepi jaepi is offline Offline
Practically a Master Poster

Re: script/function to lock a mouse and keyboard.

  #5  
Apr 10th, 2008
I think I misused the word lock, I don't really know the exact term, but it was something like it disables the use of left click (maybe). When you left click on a certain area, you cannot click on any of the buttons, but if you click again back to that area, it will enable you to click again (left click). Oh well, I'll just try to find that script again, thank you sir.
Retreat!!!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,732
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 323
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: script/function to lock a mouse and keyboard.

  #6  
Apr 10th, 2008
Maybe something like this: (untested)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv"Script-Content-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Expires" content="0"> <!-- disable caching -->
    <title>Example</title>
    <style type="text/css">
      span {
        border: 1px solid black;
        background-color: #eeffee;
        cursor: hand;
        cursor: pointer;
      }
    </style>
    <script type="text/javascript">
    // The first click will be to disable controls
    var toEnable = false;
    function enableDisable(frmName) {
      var frm = document.forms[frmName];
      if(!frm)
        return;
      var elms = frm.elements;
      for(var i = 0, size = elms.length; i < size; ++i) {
        var elem = elms[i];
        if(!elem.disabled)
          continue;
        if(toEnable) {
          elem.disabled = false;
        } else {
          elem.disabled = true;
        }
      }
      toEnable = !toEnable;
    }
    </script>
</head>
<body>
  <span onclick="enableDisable('frm');">Click here to enable/disable form controls</span>
  <br><br>
  <form id="frm" name="frm" action="#">
    <input type="text" name="txtOne">
    <br>
    <input type="submit">
  </form>
</body>
</html>
Last edited by ~s.o.s~ : Apr 10th, 2008 at 1:53 pm.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Jan 2007
Posts: 2,433
Reputation: MidiMagic is on a distinguished road 
Rep Power: 6
Solved Threads: 99
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Posting Maven

Re: script/function to lock a mouse and keyboard.

  #7  
Apr 12th, 2008
I am totally sick of website developers trying to take control of the user's computer.

That computer and its controls belongs to the owner of the computer, NOT TO YOU.

You could be charged with computer crimes if you succeed in locking part of a user's computer.

If you have files so sensitive that you don't want the user doing something with his computer, then DON'T PUBLISH THEM ON THE INTERNET.
Last edited by MidiMagic : Apr 12th, 2008 at 1:36 am.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 2:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC