zoukankan      html  css  js  c++  java
  • ASP.NET#使用母版时,如果要使用js中的getElementById()方法取得某个内容页的元素时要注意的问题

    当使用母版,要使用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="650px; height:300px" id="huifu1">
    ...
    </table>
  • 相关阅读:
    table标签去除默认边框
    自定义矢量图
    ClickJacking(点击劫持)
    css 字体不撑开默认块级元素问题
    meate 标签使用介绍
    intellij IDEA15 设置背景颜色
    JS 浮点数运算丢失精度解决方案
    IDEA 滚动条跳动问题
    JS
    异步变同步
  • 原文地址:https://www.cnblogs.com/KeenLeung/p/3295794.html
Copyright © 2011-2022 走看看