November 23, 2013

How to Disable Mouse Right Click on a Web page using JavaScript

Sometimes web page owners want to protect data such as Text and Images to be copied by others and sometimes it is about the link on the page that must be operate on same page by clicking mouse left button because of these reasons web page owners put a JavaScript code in their web pages to disable mouse Right click.

So if you want to perform same task then just copy paste below code inside your web page's <head> tag.

 <script type="text/JavaScript">  
 var message="Right-click has been Disabled";  
 function clickIE() {  
      if (document.all) {(message);return false;}}  
 function clickNS(e) {  
      if(document.layers||(document.getElementById&&!document.all)) {  
                if (e.which==2||e.which==3) {(message);return false;}}}  
      if (document.layers)  
                     { document.captureEvents(Event.MOUSEDOWN);  
                      document.onmousedown=clickNS;}  
      else{ document.onmouseup=clickNS;  
         document.oncontextmenu=clickIE;}  
 document.oncontextmenu=new Function("return false")  
 </script>  

When somebody will come to your web page and will click on page by mouse right button then a message will pop-up "Right Click has been Disabled".

November 5, 2013

How to show textbox value on message box with Jquery on button click

Here, we are working with textbox, button and pop up message box where we are showing textbox value in message box on same page on search button click using jquery.

index.jsp
put this script inside <head> tag
put this code inside <body> tag

Output:


Also Read : Jquery : Show label value on alert and browser console

How to work with History Back Button with JavaScript

In this tutorial we are working with Back Button same as History Back button of  Internet Browsers(eg. Internet Explorer, Mozilla Firefox etc.)

To understand this phenomena take an example that if you have made a search on a page(index.jsp) and you have to moved on another page(some_other_page.jsp) but you want to see previous search again then you have to back through Internet Browser Back button but you can add similar back action by coding which i am try to explain by this example with code.

index.jsp

some_other_page.jsp
script inside <head> tag

 back button code on same page inside <body> tag

Disclaimer

We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.