什么意思呢? 你是要onclick失效,这样能达到你的要求不?document.getElementByid("元素id").onclick = function(){return false}这样行吗
解决方案 »
- 怎么把javascript动态生成的行和列封装到数组中并获得动太生成的行和列的数据和限制动太生成的行数?
- 请教根据用户权限动态生成目录树!
- 脚本报错style为空或者不是对象,我想实现的功能是鼠标移动到直线,出现直线两个字,鼠标移开字消失
- 如何分别得到选中行的值?
- 单选框图片显示
- 如何控制window.showHelp()显示窗口的宽度和高度?
- 一个关于open函数的问题
- 提交问题。如果一个网页中有一个名为submit,我想自动提交这个网页怎样实现。如代码如下。
- 为什么我要点击两次才能提交呢?usernameFlag值要怎么放才好?
- javascript 的疑问
- 大侠请帮忙!
- JAVASCRIPT 传值
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript">
var fals=function(){
return false;
};
</script>
</head> <body>
<form name="docForm">
<div id="div1">
<input type="checkbox" name="chk1" onclick="fals()"/>
<input type="text" value="ss1" onclick="fals()" />
<img src="1.jpg" onclick="fals()" width="50" height="50"/>
</div>
</form> </body>
</html>
不知道LZ的目的是什么,但我觉得这个方式可以实现能看见,但不能点击里面的元素,而且也不会出现用disable属性后的变灰样式
要不就用透明层覆盖.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript"> </script>
</head> <body>
<script language="javascript">
<!--
var k=0,a=[]
function sset(_this){
var obj=document.getElementById("div1").getElementsByTagName("*")
if(k==0){
k=1
for (var i=0;i<obj.length;i++)
a[i]=obj[i].onclick
}
if (_this.checked)
for (var i=0;i<obj.length;i++)
obj[i].onclick=null
else{
for (var i=0;i<obj.length;i++)
obj[i].onclick=a[i]
}
}
//-->
</script>
<input type="checkbox" name="chk" onclick="sset(this)"/> 功能失效
<hr>
<form name="docForm">
<div id="div1">
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" />
<img src="1.jpg" onclick="alert('3');" width="50" height="50"/>
</div>
</form> </body>
</html>
能否改进一下,我的要求是这三个控件都点不着,也就是说
1.text框做出来的效果就好像是text的readonly的属性被设成true一样
2.checkbox出来的效果就好像是checkbox的disabled的属性被设成true一样
#div1{
position:relative;
width:200px;
height:100px;
}
.div{
position:absolute;
z-index:1;
width:200px;
height:100px;
background:#FF0000;
filter: alpha(opacity=10);
-moz-opacity:0.1;
opacity: 0.1;
}
</style>
<div id="div1"> <div class="div"></div>
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" />
<img src="1.jpg" onclick="alert('3');" width="50" height="50"/>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <body>
<script language="javascript">
<!--
function getPosition(theElement){
var positionX =0;
var positionY =0;
var w=theElement.offsetWidth
var h=theElement.offsetHeight
while (theElement !=null){
positionX +=theElement.offsetLeft;
positionY +=theElement.offsetTop;
theElement =theElement.offsetParent;
}
return [positionX,positionY,w,h];
}
onload=function(){
var obj=document.getElementById("div1")
var p=getPosition(obj)
var updivimg=document.createElement("img")
updivimg.src="updiv.gif"
with(updivimg.style){
position="absolute"
width=p[2]+"px"
height=p[3]+"px"
left=p[0]+"px"
top=p[1]+"px"
boeder="none"
zIndex=1000
obj.appendChild(updivimg)
}
}
//-->
</script>
<form name="docForm">
<div id="div1">
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" />
<img src="1.jpg" onclick="alert('3');" width="50" height="50"/>
</div>
</form> </body>
</html>
其中"updiv.gif"1*1像素透明图片
<!--
function getPosition(theElement){
var positionX =0;
var positionY =0;
var w=theElement.offsetWidth
var h=theElement.offsetHeight
while (theElement !=null){
positionX +=theElement.offsetLeft;
positionY +=theElement.offsetTop;
theElement =theElement.offsetParent;
}
return [positionX,positionY,w,h];
}
onload=function(){
var obj=document.getElementById("div1")
var p=getPosition(obj)
var updivimg=document.createElement("img")
updivimg.src="updiv.gif"
with(updivimg.style){
position="absolute"
width=p[2]+"px"
height=p[3]+"px"
left=p[0]+"px"
top=p[1]+"px"
boeder="none"
zIndex=1000
}
obj.appendChild(updivimg)
}
//-->
</script>
http://vip.pastein.net/kanke/natineprince/ro/RoSkill/knight.html如果只覆盖DIV的话.要计算出DIV的TOP和LEFT等属性.再把覆盖层移过去.
<style>
#div1{
position:absolute;
top:50px;
left:0px;
width:200px;
height:100px;
}
#div2{
position:absolute;
z-index:1;
width:200px;
height:100px;
background:#FF0000;
filter: alpha(opacity=10);
-moz-opacity:0.1;
opacity: 0.1;
}
</style>
<span id=control>
<input type=button value="enable" onclick="document.all.div2.style.display='block'">
<input type=button value="disable" onclick="document.all.div2.style.display='none'">
</span>
<div id="div1"> <div id="div2"></div>
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" /> </div>
修改了一下16楼的
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <body>
<style>
.updiv{filter: alpha(opacity=0); -moz-opacity:0; opacity: 0; }
</style><script language="javascript">
<!--
function getPosition(theElement){
var positionX =0;
var positionY =0;
var w=theElement.offsetWidth
var h=theElement.offsetHeight
while (theElement !=null){
positionX +=theElement.offsetLeft;
positionY +=theElement.offsetTop;
theElement =theElement.offsetParent;
}
return [positionX,positionY,w,h];
}
onload=function(){
var obj=document.getElementById("div1")
var p=getPosition(obj)
var updiv=document.createElement("div")
with(updiv.style){
position="absolute"
width=p[2]+"px"
height=p[3]+"px"
left=p[0]+"px"
top=p[1]+"px"
boeder="none"
zIndex=1000
background="#fff"
}
updiv.className="updiv"
obj.appendChild(updiv)
}
//-->
</script>
<form name="docForm">
<div id="div1">
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" />
<img src="1.jpg" onclick="alert('3');" width="50" height="50"/>
</div>
</form> </body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <body>
<style>
.updiv{filter: alpha(opacity=0); -moz-opacity:0; opacity: 0; }
</style><script language="javascript">
<!--
function getPosition(theElement){
var positionX =0;
var positionY =0;
var w=theElement.offsetWidth
var h=theElement.offsetHeight
while (theElement !=null){
positionX +=theElement.offsetLeft;
positionY +=theElement.offsetTop;
theElement =theElement.offsetParent;
}
return [positionX,positionY,w,h];
}
function yes(_this){
var obj=document.getElementById("div1")
if (!document.getElementById("updiv")){
var p=getPosition(obj)
var updiv=document.createElement("div")
updiv.id="updiv"
with(updiv.style){
position="absolute"
width=p[2]+"px"
height=p[3]+"px"
left=p[0]+"px"
top=p[1]+"px"
boeder="none"
zIndex=1000
background="#fff"
}
updiv.className="updiv"
obj.appendChild(updiv)
_this.value="disable"
}
else{
obj.removeChild(document.getElementById("updiv"));
_this.value="enable"
}
}
//-->
</script>
<form name="docForm">
<div id="div1">
<input type="checkbox" name="chk1" onclick="alert('1');"/>
<input type="text" value="ss1" onclick="alert('2');" />
<img src="1.jpg" onclick="alert('3');" width="50" height="50"/>
</div>
</form>
<hr>
<input type=button value="enable" onclick="yes(this)"></body>
</html>
2.点enable之后,我可以对三个控件操作
3.点disable之后,使鼠标点不着这三个控件. 你这三个总结起来就是改变 <div class="div"> </div>
这个的zindex值而已
改为-1就可以操作,改为1就不能操作