1 实现鼠标放上,显示导航栏,鼠标移走,隐藏导航栏 ,用div来控制
<script type="text/javascript">
function change(el) {
whichEl = document.getElementById(el) //获得指定ID值的对象
if (whichEl.style.display == 'none') { //block是默认值为显示,none为隐藏
whichEl.style.display = 'block';
} else {
whichEl.style.display = 'none';
}
}
</script>
<div class="daohang_list" id="list" οnmοuseοver="change('ctl00_ContentPlaceHolder1_list'); return false;"
style="border-right: #ff9900 1px solid; border-top: #ff9900 1px solid; display: none; background: url(../BBS/Image/bbsdaohang_bg.gif)
position: absolute; top: 141px; οnmοuseοut="change('ctl00_ContentPlaceHolder1_list'); return false;"
runat="server">
2、js获取事件的目标元素
function mouseoutHandler(oEvent,objTagName)
{
var oEvent = oEvent ? oEvent : window.event
var oElem = oEvent.toElement ? oEvent.toElement : oEvent.relatedTarget; // 此做法是为了兼容FF浏览器
alert(oElem.id); // 当鼠标移出Div1时,会弹出提示框提示鼠标移动到的另一个元素的ID
}
<div οnmοuseοut="mouseoutHandler(event)" id="div1" style=" width:50px; height:50px;">div1</div>
<div id="div2" style="width:50px; heigth:50px;" >div2</div>
3.c#里弹出模态窗口且最大化
string jScript = "window.showModalDialog(\"CoursewarePlay.aspx?coursewareId=" + e.CommandArgument.ToString() + "\", window, \"resizable:yes;scroll:yes;status:no;dialogWidth: \"+window.screen.width+ \"; dialogHeight: \"+window.screen.height+ \"; center=yes;help=no\");";
ClientScript.RegisterStartupScript(typeof(string), "openAndPlay", "<script>" + jScript + "</script>");
备注:window.screen.height 屏幕的高度 window.screen.width屏幕的宽度
4.用户控件的js查找控件的id
document.getElementById("<%=HiddenBrowserWidth.ClientID%>").value = browserWidth;
用户控件里的服务器控件id为:HiddenBrowserWidth,在页面里的id会加上前缀的,所以js里面用("<%=HiddenBrowserWidth.ClientID%>"),这是控件在客户端的id