文章出處

當使用母版,要使用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>

 


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()