<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head> <body>
<div style="width:100px; height:100px; background:#09C;"
</body>
<script type="text/javascript">
//F5
document.documentElement.onkeydown=function(e){
e=e||window.event;
if(e.keyCode==116){
if(e.returnValue){
e.returnValue=false;
}else{
e.stopPropagation();
}
return false;
}
}
//右键
document.documentElement.oncontextmenu=function(e){
e=e||window.event;
e.cancelBubble = true;
e.returnValue=false;
return false;
}
</script>
</html>

没有测试

已经测试了的

/**--  禁止F5刷新 针对IE --**/
document.onkeydown = function()
{
/*
(ctrlKey == true && keyCode == 82) Ctrl+R ---刷新
(keyCode == 116) F5 ---刷新
(ctrlKey == true && keyCode == 116) Ctrl+F5 ---强制刷新
*/
//alert(event.keyCode);
var k = event.keyCode;
if((event.ctrlKey == true && k == 82) || (k == 116) || (event.ctrlKey == true && k == 116))
{
//return (window.confirm("关闭?"));
event.keyCode = 0;
event.returnValue = false;
event.cancelBubble = true;
}
}

禁止鼠标右键

<body onselectstart="return false">

JS 禁止刷新和右键的更多相关文章

  1. js禁止默认的右键菜单或出现自定义右键菜单

    1.屏蔽默认的右键菜单 js: document.getElementById('myimg').oncontextmenu=function(){return false;} jquery: $(' ...

  2. JS 禁止F12和右键操作控制台

    1.鼠标点击事件 document.onmousedown = function mdClick(event) { var e = event || window.event || arguments ...

  3. JS 禁止IE用右键

    <!--组合键: -->IE的键盘监听最多只能作用于document上(window我试过不行)如果内嵌了iframe并且你的焦点在iframe上,那么按键无效 这里我用CTRL+Q写的例 ...

  4. js禁止刷新的简单方法

    //禁止用F5键  这个是键盘按下时触发document.onkeydown = function() { if ( event.keyCode==116) {event.keyCode = 0; e ...

  5. js禁止网页使用右键

    document.oncontextmenu=function(){ return false }

  6. JS 禁止右键,禁止复制,禁止粘贴

    原文:JS 禁止右键,禁止复制,禁止粘贴 如何用用javascript 禁止右键,禁止复制,禁止粘贴,做站时常会用到这些代码,所以收藏了一下!1. oncontextmenu="window ...

  7. js禁止

    很多时候需要用到js禁止相关的代码: function prohibit() { // 禁止右键 $(document).ready(function() { $(document).bind(&qu ...

  8. JS定时刷新页面及跳转页面

    JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...

  9. JS实现刷新iframe的方法

    <iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe> ...

随机推荐

  1. Diamond Collector

    Diamond Collector 题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining ...

  2. BroadcastReceiver的两种注册方式之------动态注册

    activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  3. DWR整合之JSF

    DWR 与 JSF DWR 包括两个 JSF 的扩展点,一个创造器和一个 ServletFilter. 1.JSF Creator DWR1.1 中有一个体验版的 JsfCreator.你可以在 dw ...

  4. C#对象序列化笔记

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.R ...

  5. python数组查找算法---bisect二分查找插入

    1 实例 这个模块只有几个函数, 一旦决定使用二分搜索时,立马要想到使用这个模块 [python] view plaincopyprint? import bisect L = [1,3,3,6,8, ...

  6. lang

    我的docker容器里边,运行我的java进程时环境变量LANG为空导致乱码,重启java进程不为空显示正常:没有地方显式的设置过LANG,没找到/etc/(environment,profile,l ...

  7. ffmpeg ffplay ffprobe资料整理

    1. 官网地址:https://ffmpeg.org/ 官网文档地址:https://ffmpeg.org/documentation.html 官网下载地址:https://ffmpeg.org/d ...

  8. Hibernate---基础配置

    hibernate.cfg.xml里可以设置一个值显示更详细的sql语句: <property name="format_sql">true</property& ...

  9. HDU 2498 Digits

    水题.题目这样定义的,另f(x)为x有几位,x[i]=f(x[i-1]); 求最小的i使得x[i]==x[i-1] #include<cstdio> #include<cstring ...

  10. NodeJs-- 新建项目实例

    安装Nodejs: 下载地址:http://nodejs.org 设置环境变量,例如我将nodejs装在D:/program文件夹下,则设以下为系统环境变量 D:\Program\nodejs 安装E ...