[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

enable mouse disabled by script

Hi,

I saw this website http://www.pesten.net/ where it is made imposible to select/copy text or open the context menu. What is the easiest way to enable it again?

This is the source responsible:

<script type="text/javascript" language="JavaScript">
<!--

function dno() {
  return false
}

function omu(e) {
  if(e.which==1){
    window.releaseEvents(Event.MOUSEMOVE);
    window.onmousemove=null
  }
}

function jk(){
  alert(unescape("This function is not available."));
  return false
}

function kj(e){
  if(e.which==1){
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove=dno
  }
  if(e.which==3){
    return jk()
  }
}

function ct(){
  hg=event.button;
  if(hg==2||hg==3) jk()
}

vc=document.all;
qb=document.getElementById;

if(vc){
  if(qb){
    document.oncontextmenu=jk;
    document.onselectstart=dno;
    document.ondragstart=dno
  }else{
    document.onmousedown=ct
  }
}

if(qb&&!vc){
  document.onmousedown=dno;
  document.onmouseup=kj;
  document.oncontextmenu=dno
}

if(document.layers){
  window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
  window.onmousedown=kj;
  window.onmouseup=omu
}

function qa0(){
  window.status=" ";
  setTimeout("qa0()",50)
}

qa0();

function qa1(){
  return true
}

if(document.all||document.getElementById)
  document.body.onmouseover=qa1
//-->
</script>

I was able to solve it for myself using the javascript console in firebug, but don't want to do that each time and I want to explain it to a non-technical person using IE.
0
cwwkie
Asked:
cwwkie
  • 5
  • 4
  • 4
  • +1
1 Solution
 
Pravin AsarCommented:
<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
</head>
<body>
<script language="javascript">
var fnPtr = document.oncontextmenu;
function Block () {
   fnPtr = document.oncontextmenu;
   document.oncontextmenu = function () { alert('OOPS'); return false;};
}
function UnBlock () {
   document.oncontextmenu = fnPtr;
}
</script>
This lets you block and unblock the contextmenu (enable by Right Mouse

Button (RMB) click.
<br>
<form>
<input type="button" onClick="Block();" value="Block R M B">
<input type="button" onClick="UnBlock();" value="UnBlock R M B">
</form>
</body>
</html>
0
 
ClickCentricCommented:
Are you asking how to break it as the developer or how to break it as an end user?  If it's the latter, then the easiest way is to have them use keyboard controls to select all, copy and paste.
0
 
ClickCentricCommented:
Another alternative is to have them disable jascript and hope that it doesn't break the part of the page that they need to select and copy.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ClickCentricCommented:
jascript=javascript
0
 
cwwkieAuthor Commented:
> Are you asking how to break it as the developer or how to break it as an end user?

As an end user. It is not my page.

I thought I had tried select all using the keyboard, but it was not working, but now I am trying it again, and it seems to work. It is still not possible to open the context menu, but if I am able to copy it without losing formatting, it is not important any more.

btw, when I disable javascript, the page does not show.
0
 
cwwkieAuthor Commented:
On firefox I can use the keyboard to select and copy the text, but on internet explorer it is not working. even copying and pasting in notepad is not working any more when that page is loaded. It seems to continiously clear the clipboard. Very nasty....
0
 
ClickCentricCommented:
Hmm...there's may be no real universal solution for you, then.  I'm guessing that simply providing you with the url won't give you what you need?
0
 
basicinstinctCommented:
The way to enable the context menu on any page, while still keeping javascript active, is to use a bookmarklet.  You can get the one I wrote here:

http://malydog.homeip.net/bookmarklets.html

I just saw my site is playing up, looks like Tomcat is down, you should still be able to get the bookmarklet though.

Here's the code anyway (must all remain on one line):

javascript:(function(){document.onmouseup="";document.onmousedown="";document.oncontextmenu="";})();

0
 
basicinstinctCommented:
To test it, go to the site in question, paste the code into the Address box (where you normally type http://www.stuff.com) and paste in the code.  Then hit enter and now your right click works!  Feel free to name your first born child after me.
0
 
basicinstinctCommented:
For long term use, create a new bookmark / favorite and put the code as the target of the bookmark.  Now it's ready to go on any page.  It's best in "Links" or the "Bookmarks Toolbar".
0
 
ClickCentricCommented:
You know, I've thought about such things before, but I always just assumed that they wouldn't work because of security implications...I assumed they'd only work if clicked on within a page...but indeed it does work.  It won't let cwwkie do what he wants with that page because of how it's rendered, but that's a limitation of IE....the bookmarklet does do what you what it's meant to do, though.
0
 
cwwkieAuthor Commented:
> Hmm...there's may be no real universal solution for you, then.  

I don't need an universal solution, It only needs to work on www.pesten.net

> The way to enable the context menu on any page, while still keeping javascript active, is to use a bookmarklet.

If I first disable "Allow past operations via script." in security settings of IE, I can copy the line:
    javascript:(function(){document.onmouseup="";document.onmousedown="";document.oncontextmenu="";})();
But to select any text, I also need to add these:
    document.onselectstart=""; document.ondragstart="";

That seems to work now...
0
 
basicinstinctCommented:
yeah, he had more than just the context menu disabled
0
 
cwwkieAuthor Commented:
for future reference, here is a greasemonkey version of the script.

// ==UserScript==
// @name            www.pesten.net
// @description     enable mouse on www.pesten.net
// @include         http://www.pesten.net/*
// ==/UserScript==

(function () {
    unsafeWindow.document.onmouseup="";
    unsafeWindow.document.onmousedown="";
    unsafeWindow.document.oncontextmenu="";
    unsafeWindow.document.onselectstart="";
    unsafeWindow.document.ondragstart="";
})();
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now