We help IT Professionals succeed at work.

tracking mouse right click - refresh option

abas asked
Hi all,

     I am developing an application wherein I am having a form contains a checkbox.  User will  select/check the checkbox and press the submit button.  This action will update the database after necessary validations.

My problem is,   if  I/user press right mouse click in the browser and asks to refresh the page,  browser consider this as a new request and forwards the old query again.  This leads to certain undesired effects in the database.  Could any one of you  let me know how to track the  mouse right click - refresh option so that I can prevent my applications from unnecssary updates.  Solutions can be in VB Script also.

Hope you understand my problem.

Thanks and regards
Watch Question

<script language="JavaScript">
<!-- begin right_click trap
     if (document.layers) window.captureEvents(Event.MOUSEDOWN); window.onmousedown=click;
     function click(e)
          if (navigator.appName == 'Netscape')
               if (e.which != 1)
                    alert("Hi! How are you?");return false;
          if (navigator.appName == "Microsoft Internet Explorer")
               if (event.button != 1)
                    alert("Hi! no right click");return false;
//-- end>
No Right click

This prevents the right click menu display, but i don't think this is the right solution for your problem, as there is an option to the user to refresh page by pressing F5(for IE) and Ctrl+R (for NN) and they can even click on Refresh/Reload button on the browser.

Good Luck...:)

In fact, you can't do this. The only thing you can do is disable user right click only.
This is the reason why it is customary to display a successful message page after a submit process. You can have a link in the page that will redirect the user back to the re-initialized form.

You can also try to submit the form to a different ASP containing only script code for processing the request. The last line of the ASP Response.Redirect()s back to the form page.

If you don't want to do those things suggested above, ensure that your ASP code encourages re-initialization of page form state/mode. I usually hardcode the following code in my form:

<input type='hidden' name='txtMyMode' value=''>

Note the hard-coded empty value (value=''). I then add a javascript to trap/execute any form submit, like this:

<script language="JavaScript">
function submitForm(frm, sAction) {
 frm.txtMyMode.value = sAction;

My buttons will have the like following code:

<input type='button' name='btn' value='Add' onclick="javascript:submitForm(document.form1, 'Add')">

Use these hard-coded value instead to test in ASP if you are suppose to process or not:

If Request("txtMyMode") <> "" Then
 Select Case Request("txtMyMode")
  Case "Add"
  Case "Delete"
  Case Else
 End Select
End If

ahosangFinance Systems Developer

This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
ahosangFinance Systems Developer

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to etmendz
Please leave any comments here within the next seven days.
EE Cleanup Volunteer
Per recommendation, force-accepted.

EE Admin

Explore More ContentExplore courses, solutions, and other research materials related to this topic.