Solved

stop refresh

Posted on 2001-06-25
12
528 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

813 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

17 Experts available now in Live!

Get 1:1 Help Now