Solved

stop refresh

Posted on 2001-06-25
12
526 Views
Last Modified: 2008-03-17
Is there a way to stop the user from refreshing the page.
1) disable F5
2) stop refresh using context menu

The cancelBubble property works for disabling the opening of a new window using "CtrlKey + N".

Please do throw some light on this property too ( when it works and when it doesn't )

rgds
jcs
0
Comment
Question by:jcs_clement
  • 6
  • 5
12 Comments
 
LVL 1

Expert Comment

by:katyan
Comment Utility
listening
0
 
LVL 9

Expert Comment

by:nimaig
Comment Utility
Check this. It prevent the user from right click and also prevents refresh by F5. Still the user has the option of
refreshing the page from main menu. So you need to open a new window without any of these menus.

Hope this helps !!!!

<html>
<head>
<script language="JavaScript1.2">
function keyPressed(evt) {
   var F5 = 116;
   if(document.layers) {
             if (evt.which == F5) {
              return false;
           }
   }else if(document.all){
          if (event.keyCode == F5) {
               event.keyCode = 0;
                window.event.returnValue = false;
             }
   }
}

function click(e) {
     if (document.all) {
          if (event.button == 2) {
               alert("Sorry, that function is disabled");
               return false;
          }
     }
     if (document.layers) {
          if (e.which == 3) {
               alert("Sorry, that function is disabled");
               return false;
          }
     }
}

if(document.layers){
     window.captureEvents (Event.KEYDOWN);
     document.captureEvents(Event.MOUSEDOWN);
     window.onkeydown=keyPressed;
     window.onmousedown=click;
}else{
     document.onkeydown=keyPressed;
     document.onmousedown=click;
}
</script>
</head>


<body>

</body>
</html>
0
 
LVL 4

Author Comment

by:jcs_clement
Comment Utility
Great one !!.
The context menu in NS 4.7 does not throw an alert when I right click. Can u please check that one and let me know ?

rgds
jcs
0
 
LVL 9

Accepted Solution

by:
nimaig earned 50 total points
Comment Utility
Sorry ... I forgot to test in Netscape. This code should work.

<html>
<head>
<script language="JavaScript1.2">
function keyPressed(evt) {
   var F5 = 116;
   if(document.layers) {
             if (evt.which == F5) {
              return false;
           }
   }else if(document.all){
          if (event.keyCode == F5) {
               event.keyCode = 0;
                window.event.returnValue = false;
             }
   }
}

function click(e) {
     if (document.all) {
          if (event.button == 2) {
               alert("Sorry, that function is disabled");
               return false;
          }
     }
     if (document.layers) {
          if (e.which == 3) {
               alert("Sorry, that function is disabled");
               return false;
          }
     }
}

if(document.layers){
     document.captureEvents(Event.MOUSEDOWN);
     document.captureEvents (Event.KEYDOWN);
}
document.onkeydown=keyPressed;
document.onmousedown=click;
</script>
</head>


<body>

</body>
</html>
0
 
LVL 4

Author Comment

by:jcs_clement
Comment Utility
Great one !!.
The context menu in NS 4.7 does not throw an alert when I right click. Can u please check that one and let me know ?

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
Comment Utility
Hi,
I am using Netscape 4.7 and the code works fine.

Nimai
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 4

Author Comment

by:jcs_clement
Comment Utility
Thanks great one !!

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
Comment Utility
Hi jcs,
 Thanks :) Are you in Planetasia, Kormangala office(Near Aztec software). I am also working in a company in Kormangala itself.
 
 Nimai
0
 
LVL 4

Author Comment

by:jcs_clement
Comment Utility
Yeah u are right. Where are u now...?

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
Comment Utility
I am working in Wisor Telecom.
0
 
LVL 4

Author Comment

by:jcs_clement
Comment Utility
Hi will u give me your mail id ..?
Lets' keep in touch.
Mine is jcs_clement@yahoo.com

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
Comment Utility
Hi jcs,
Thanks for you mail Id.
You can mail me at this mail Id.
nimaig@yahoo.com

Nimai
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now