Monday, November 24, 2008

JavaScript Tutorials

HTML clipboardHTML clipboard
  • Script for No Enter Action:
JavaScript function for No Action when enter button is pressed in the page.

function noenter()
{
var key;
if(window.event)
key = window.event.keyCode; //IE
return (key!= 13); //13 ASCII code
}

the page_load event call this method as:

this.Form.Attributes.Add("onkeypress", "return noenter()");

  • Script for Browser Back Disable & Browser Back:
<scripttype ="text/javascript">
javascript:window.history.forward(1);<script>

javascript:history.back(1)and also for Browser back.

  • Script for Right Click Disable:
<body onContextmenu = "alert('Right Click not Allowed!');return false;">

  • Script for alert message while closing (Unloading) the Page:
<body onbeforeunload="alert('You are about to close the window');">

No comments: