dcsimg
Preventing Page Refresh thru prevention of right click and key press using Javascript in IE 5+, Netscape 4.7 and Netscape 6.+
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhishek_Vijaygopal
Posted On:   Monday, May 19, 2003 08:34 AM

Hi, I am coding an application which will have a back end timer running, and I want to prevent the page being refreshed ny the user.



In this regard, I want some Javascript which would help me disable the right click, and the entire keyboard, leaving only the left click enabled. Could someone pls help me out as it is urgent. The code needs to be compatible for IE 5+, Netscape 4.7, and Netscape 6+.



Pls help! Thanks






Abhishek

Re: Preventing Page Refresh thru prevention of right click and key press using Javascript in IE 5+, Netscape 4.7 and Netscape 6.+

Posted By:   Nitesh_Naveen  
Posted On:   Wednesday, May 21, 2003 02:13 AM

Here's the code for disabling right click in all browsers you need... Put this code within script tags in head

function disableClick(evnt)
{
if(document.all)
{
alert("Sorry... Right click is not allowed.");
return false;
}
if(navigator.appName=="Netscape")
{
if(evnt.which==3)
{
alert("Sorry... Right click is not allowed.");
return false;
}
}
}
document.oncontextmenu = disableClick;
if(!document.all && document.getElementById)
document.onclick = disableClick;
if(document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = disableClick;
}

Re: Preventing Page Refresh thru prevention of right click and key press using Javascript in IE 5+, Netscape 4.7 and Netscape 6.+

Posted By:   Nitesh_Naveen  
Posted On:   Wednesday, May 21, 2003 01:52 AM

See this faq (click here). But I guess it doesn't work for Netscape 4.7x etc... Couldn't find any alternative either. Will post if i come across any
About | Sitemap | Contact