Solved

stop refresh

Posted on 2001-06-25
12
527 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

919 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

16 Experts available now in Live!

Get 1:1 Help Now