View Full Version : silent no left-click script

03-21-2004, 08:41 PM
I looked for and couldn't find.
I tried to convert a script with alert to a silent one and didn't succeed.
Can anyone help please?


03-21-2004, 10:19 PM
:confused: If users can't left click, how are they gonna get around your site?

03-21-2004, 10:53 PM
see this thread http://codingforums.com/showthread.php?s=&threadid=4437

please dont disable left or right click, it doesnt do anything for you and it pisses people off

03-22-2004, 07:24 AM
Come on!
Please answer my question!
I don't want to disable it (and if one wants to do it, who are you to judge him? visitors'll judge him - they won't come to his webpages...)

All I want to do is to disable it from <head> and then onLoad, to enable it (because when someone clicks on something - the page stops loading).
I want the page to load before anyone can click.


03-22-2004, 08:47 AM
Try the following:
window.onclick=function(){return false;}
delete window.onclick;
}If that doesn't work, try removing delete and instead setting it to null.

03-22-2004, 10:14 AM
IE listens on document.onclick not window.onclick, unlike in Moz where it listens on both. But disabling it won't disable the clicks in links and buttons.

03-22-2004, 10:44 AM
maybe I can solve the problem from the problematic function:

function showCont(articleID){
contTd = eval(document.getElementById("ContTD_" + articleID));
if(contTd.style.display == "none") {
contTd.style.display = "block";
} else {
contTd.style.display = "none";


<a href="javascript:showCont("12")">

But if someone clicks this anchor before the page loads, all of the loading process is stopped.
Is there a way to void it?

03-22-2004, 10:52 AM
You might try using mouse capture for IE... there's an example here (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/releasecapture.asp).

03-22-2004, 10:54 AM
function showCont(articleID){
var contTd = document.getElementById("ContTD_" + articleID);
if (!contTd) return;
if(contTd.style.display == "none") {
contTd.style.display = "block";
} else {
contTd.style.display = "none";

Note: You don't have to use eval().

03-22-2004, 11:08 AM
but still, clicking before full load, stops the loading :\

03-22-2004, 02:30 PM
ok, for IE only:


onload = new Function()
document.body.onmousedown = (document.readyState == "completed") return true : return false ;

just guessing, really :-)

Roy Sinclair
03-22-2004, 06:13 PM
Just as an aside, why is it important that the full page load before the user can continue?

I ask this because I often click through intermediate pages on some sites before they are completely loaded. There's usually nothing of interest for me on those pages except the next link so I don't want to have to wait. Also some pages never do finish loading, the advertisements on web pages can be problematic so if you pages have any ads, those ads can cause a "never finished loading" problem and this code could basically lock out your user.

Then as a second question, why has this become a problem? Is there something about that page which makes it very slow in loading? Why doesn't the page come up so quickly that the user doesn't have time to click on a link within the page before the page completes loading. It's not always possible to make a page that quick but if early clicking is a problem, then figuring out how to make the page load near instantly is the best possible solution and scripts like the one suggested above would (and should) fall futher down the chain of solutions.

I ask those question mainly because I want you to think about the why and what. Maybe there's a solution that'll work better for you and your users than this idea.

03-22-2004, 06:34 PM
The page loads quite quickly.
The problem is the hide/show links.
When a user clicks on the link (which triggers the function I attached before), the page stops loading (some little gif's at the bottom of the page won't load after clicking the hide/show link).

Most people won't even notice the problem, but fast-clickers like me will...

Maybe the problem is with my JS.
Why does clicking (the hide/show links) stop the page from loading anyway?

(PS: I have no ads in this pages whatsoever :) )

Roy Sinclair
03-22-2004, 07:25 PM
Ok, you understand why you need this. :)

I have one case where I needed something similar but I went a different route. I placed a <div> over the whole page styled like this:

font-size: 95pt;
background-color: gray;
font-family: Arial, sans-serif;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
text-align: center;

called this function onload:

function fadeInPage()
if (document.layers)
document.layers['loadingDiv'].visibility = 'hidden';
return true;
if (document.getElementById("loadingDiv").filters.alpha.opacity > 0)
document.getElementById("loadingDiv").filters.alpha.opacity -= 5;
document.getElementById('loadingDiv').style.visibility = "hidden"

and the DIV itself follows the <body> tag:

<div id="loadingDiv" class="lDiv" style="filter:alpha(opacity=50);">
Please Wait

It should be noted that the use of the MS filter has caused some difficulties, it seems that some IE 6 users have trouble because the IE 6 install silently failed to complete and the filters didn't install which breaks the page for those users. I'm reworking that page soon and the filter will become history then.

The upshot of what I did is that this put's an overlay on the page with a "Please Wait" notice yet the user can see the page loading through the overlay which is removed when the page is complete. The user can't access anything on the page though until the overlay is removed. In my case this was done because there's javascript running which builds a huge table (in some cases, in other cases it's a small table) and I needed to hold the user back until the table was complete (sound familiar?).

03-23-2004, 02:05 AM
The div will only cover the visible screen from the top. If the page is long and has scrollbar, the user can still click the document that is not covered by the div.