文章出處
文章列表
當使用母版,要使用js中的getElementById()方法取得某個內容頁的元素時,所選取的id并不是母版中內容頁的id,而是在設計內容頁時設定的id
例子:
母版頁:
...... <head runat="server"> <title>無標題頁</title> <link href="../css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript"> function fff() { var text = document.getElementById("huifu1");//要取得內容頁的元素 if (text != null) { text.focus(); } } </script> </head> <body style=" color:Black"> <form id="form1" runat="server"> <div id="outer"> <div id="inner"> <div> <uc1:liuyan ID="liuyan1" runat="server" /> </div> <br /> <br /> <uc2:huifu ID="huifu1" runat="server" />//要取得的元素應該是在該內容頁面中 </div> </div> </form> </body> </html>
內容頁:
<table style="width:650px; height:300px" id="huifu1"> ... </table>
文章列表
全站熱搜