<script language="javascript">
function SelectAllUser(controlID)
...{
var ele = event.srcElement;
if(ele.type=='checkbox') 
...{
var checkBoxs = document.getElementsByTagName( "INPUT" );
for(var i=0;i<checkBoxs.length;i++) 
...{
if(checkBoxs[i].type=='checkbox' && checkBoxs[i].id.indexOf("QCheckBoxUserList") != -1) 
...{
checkBoxs[i].checked = ele.checked;
}
}
}
}
function HideUserList(controlID)
...{
document.getElementById(controlID).style.display = "none";
return false;
}
function ShowUserList(controlID)
...{
//document.getElementById("MailDIV").style.display = "none";
//document.getElementById("UserListDIV").style.display = "none";
var the = event.srcElement;
var div = document.getElementById(controlID);
//alert(document.body.clientHeight + " " + event.y + " " + div.offsetHeight);
if(document.body.clientHeight - event.y - 20 <= div.offsetHeight)
...{
div.style.top = event.y - div.offsetHeight;
}
else
...{
div.style.top = event.y;
}
if(div.offsetHeight == 0)
...{
div.style.top = event.y - 200;
}
div.style.right = document.body.clientWidth - event.x + 25;
div.style.display = "block";
return false;
}
</script>只需要在我们的DIV前加IFrame作为底层
<iframe style="position: absolute; z-index: 9; width: expression(this.nextSibling.offsetWidth);
height: expression(this.nextSibling.offsetHeight); top: expression(this.nextSibling.offsetTop);
left: expression(this.nextSibling.offsetLeft);" frameborder="0"></iframe>
<div id="UserListDIV" style="position: absolute; display: none; background-color: White;
z-index: 19; width: 150px;">
<table>
<tr>
<td>
<BenQ:QCheckBox ID="QCheckBoxAll" runat="server" Text="All" AutoPostBack="false"
onclick="javascript:SelectAllUser(this)" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList0" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList1" runat="server" Text="Lionel Li" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList2" runat="server" Text="Laker Yan" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList3" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList4" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList5" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList6" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList7" runat="server" Text="Jason Xu" /><br>
<BenQ:QCheckBox ID="QCheckBoxUserList8" runat="server" Text="Jason Xu" /><br>
</td>
</tr>
<tr>
<td style="text-align: center">
<BenQ:QButton ID="QButtonSubmit" runat="server" Text="Save" Type="submit" />
<span class="Span5"></span>
<BenQ:QButton ID="QButtonCancel" runat="server" Text="Cancel" Type="common" OnClientClick="return HideUserList('UserListDIV');" />
</td>
</tr>
</table>
</div>
本文介绍了一个使用JavaScript实现的用户列表弹窗功能。该功能通过点击按钮显示或隐藏包含多个用户选项的弹窗,并能一键全选所有用户。此外,还详细展示了如何定位弹窗并确保其始终位于页面可见区域内。
4402





