faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

198 of 238 people (83%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I prevent the F5 key from refreshing current page ?

Sep 28th, 2001 03:29
bogo, Colin Fraser, DUY DO PHAN,


On IE:
<script language=JavaScript1.2>
// IF IE:
if (document.all)
{	 	
	document.onkeydown = function ()
	{
	        var key_f5 = 116; // 116 = F5		
		if (key_f5==event.keyCode)
		{
			event.keyCode=0;
			alert ("F5 was press!");
		}
		return false;
	}
}
</script>