61,112
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
function <%= RoomDiv.ClientID %>openDetail()
{
$.XYTipsWindow({
___title: "详细信息",
___content: "iframe:../Controls/BuildingControl_RoomDisplay.aspx",
___width: "400",
___height: "300",
___drag: "___boxTitle",
___showbg: true,
___offsets: "middle-top"
});
}
</script>
<div id="RoomDiv" runat="server" class="DisplayDiv" onclick="">
<div class="ONLineEnergyWin">
<a onclick="其他弹框方法">
<asp:Label ID="Label1" runat="server"></asp:Label>
</a>
</div>
other
</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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>绝对定位相对定位</title>
<style>
.fj1 { width: 150px; position: relative; height: 150px; border: 1px solid #000; background: #999; margin: 0 auto; }
</style>
<script>
function aClick(){
alert("a");
return false;
}
function divClick(div){
if(window.event.srcElement.tagName=="SPAN")
{
return;//判断如果点击的是A链接,就不弹详细框
}
alert("div");
}
</script>
</head>
<body>
<div onclick="divClick();" class="fj1">
<div >
<a onclick="aClick();"><SPAN>我是A标签</SPAN></a>
</div>
</div>
</body>
</html>
function click(e){
preventDefault(e);//这句加在A标签弹框前面,就只弹DIV的框。 如果加在A弹框的后面,DIV和A的框都弹出来了。
}
//假设,你A上绑定的函数是click
function click(e){
preventDefault(e);//在函数最后,绑定这个。如果你这个函数有传入参数的话,那就把这个函数,再次绑定到A标签上。如果你是onclick="click(参数1,参数2);preventDefault(e);",那就这样绑两个。最好还是click不传其他参数,直接把这个函数,写在click内部。
}
function preventDefault(e){
//组织继续冒泡的函数
e = e || window.event;
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue = false;
}
}
先试试,你之后再去查相关的内容吧。。。加一下这些代码,就不会执行DIV的click事件了
<script>
function aClick(){
alert("a");
return false;
}
function divClick(div){
if(div !== window.event.srcElement){
return;
}
alert("div");
}
</script>
<div onclick="divClick(this);">
<a onclick="aClick();">test</a>
</div>
上面的不支持ie[/quote]
用的第二个方法
<script>
function aClick(){
alert("a");
return false;
}
function divClick(div){
if(div !== window.event.srcElement){
return;
}
alert("div");
}
</script>
<div onclick="divClick(this);">
<a onclick="aClick();">test</a>
</div>
上面的不支持ie
<script>
function aClick(){
alert("a");
return false;
}
function divClick(){
if(window.event.currentTarget !== window.event.srcElement){
return;
}
alert("div");
}
</script>
<div onclick="divClick();">
<a onclick="aClick();">test</a>
</div>
<script type="text/javascript">
function <%= RoomDiv.ClientID %>openDetail()
{
$.XYTipsWindow({
___title: "详细信息",
___content: "iframe:../Controls/BuildingControl_RoomDisplay.aspx?RoomBindingDataSeqId=<%=SeqId %>",
___width: "400",
___height: "300",
___drag: "___boxTitle",
___showbg: true,
___offsets: "middle-top"
});
}
function urlSki(MaterCode, MaterName, MaterType, Unit, TypeName, KeyB, KeyC, IsReal, autoMatic) {
var win = window.open("../../View/Energyfile/FrmONLineEnergy.aspx?from=FrmONLineEnergy&MeatrCode=" + escape(MaterCode)
+ "&MaterName=" + escape(MaterName)
+ "&MaterType=" + escape(MaterType)
+ "&Unit=" + escape(Unit)
+ "&TypeName=" + escape(TypeName)
+ "&KeyB=" + escape(KeyB)
+ "&KeyC=" + escape(KeyC)
+ "&Automatic=" + escape(autoMatic)
+ "&IsReal=" + escape(IsReal)
+ "&LinkName=" + escape(MaterName)
+ "&LinkCode="
+ "&LinkModel=1", 'ONLineEnergyWin', 'height=600, width=950, top=0,left=0, toolbar=no, menubar=no, scrollbars=auto, resizable=yes,location=no, status=no');
win.focus();
stopPropagation(e);
}
function stopPropagation(e){
e = e || window.event;
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true;
}
}
</script>
<div id="RoomDiv" runat="server" class="DisplayDiv" onclick="">
<div class="ONLineEnergyWin">
<a onclick="其他弹框方法">
<asp:Label ID="Label1" runat="server"></asp:Label>
</a>
</div>
other
</div>
function stopPropagation(e){
e = e || window.event;
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true;
}
}
又把window给拼写错了,脑子犯晕了。function stopPropagation(e){
e = e || windwo.event;
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true;
}
}