Link to home
Start Free TrialLog in
Avatar of cwwkie
cwwkie

asked on

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.
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

<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>
Avatar of ClickCentric
ClickCentric

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.
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.
jascript=javascript
Avatar of cwwkie

ASKER

> 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.
Avatar of cwwkie

ASKER

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....
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?
ASKER CERTIFIED SOLUTION
Avatar of basicinstinct
basicinstinct
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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".
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.
Avatar of cwwkie

ASKER

> 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...
yeah, he had more than just the context menu disabled
Avatar of cwwkie

ASKER

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="";
})();