javascript 效果(導航)

來源:互聯網
上載者:User

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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.