Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

stop refresh

Posted on 2001-06-25
12
529 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
ID: 6226444
listening
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6226578
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
ID: 6226600
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
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.

 
LVL 9

Accepted Solution

by:
nimaig earned 50 total points
ID: 6226625
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
ID: 6226647
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
ID: 6226648
Hi,
I am using Netscape 4.7 and the code works fine.

Nimai
0
 
LVL 4

Author Comment

by:jcs_clement
ID: 6226651
Thanks great one !!

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6226671
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
ID: 6226690
Yeah u are right. Where are u now...?

rgds
jcs
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6226725
I am working in Wisor Telecom.
0
 
LVL 4

Author Comment

by:jcs_clement
ID: 6226813
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
ID: 6226840
Hi jcs,
Thanks for you mail Id.
You can mail me at this mail Id.
nimaig@yahoo.com

Nimai
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

808 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