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" onmouseover="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; onmouseout="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 onmouseout="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