<!DOCTYPE html>
<!--导入模板标签!!!!!-->
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>输入框的一些禁止操作</title>
<script type="text/javascript">
function f1() {
debugger
/*值不要加“”,用''*/
document.getElementById("id1").value='disabled的效果';
document.getElementById("id2").value='readonly的效果';
document.getElementById("id3").placeholder='朱亚萍';
document.getElementById("id4").type='text';
}
function f2(x) {
x.type='text';
}
function f3(x) {
x.type='password';
}
</script>
</head>
<body>
<input type="text" value="禁止复制" oncopy="return false" placeholder="禁止复制"/>
<br/>
<input type="text" value="禁止粘贴" onpaste="return false" placeholder="禁止粘贴"/>
<br/>
<input type="text" value="禁止剪切" oncut="return false" placeholder="禁止剪切"/>
<br/>
<div onselectstart="return false">无法选中</div>
<br/>
<input type="text" oncontextmenu="return false" value="禁止右键"/>
<br/>
<input id="id1" type="text" disabled="true" value="不可编辑"/>
<br/>
<input id="id2" type="text" readonly="true" value="不可编辑1">
<input type="submit" onclick="f1()" value="赋值"/>
<br/>
<!--让type从password变成text密码就显示-->
<input id= "id4" type="password" placeholder="请输入密码" onmouseover="f2(this)" onmouseout="f3(this)">
鼠标移入显示密码,移走密码隐藏</input>
<br/>
<input id= "id5" type="password" placeholder="请输入密码" onmousedown="f2(this)" onmouseup="f3(this)">
鼠标按下显示密码,拿走密码隐藏</input>
</body>
</html>
js一些禁止操作和鼠标操作
最新推荐文章于 2023-08-26 11:44:17 发布