gPopupMask = document.getElementById("popupMask")你这样注册脚本的时候,HTML上面那个popupMask还没生成的吧

解决方案 »

  1.   

    1.延迟到加载完后,再往页面底部添加js;
    2.jquery的ready。
      

  2.   

    直接用JS或者JQ在前端处理吧。这样注册JS要等后台都处理完了才会加载到前端页面上的。
      

  3.   

    看不懂这是什么
    看下RegisterStartupScript 的API就知道了楼主可以 后台把html拼接好 然后返回给前台  前台处理数据 
      

  4.   

         我的思路是:在A.aspx页面执行完毕后通过RegisterStartupScript跳转到B.aspx页面然后弹出遮盖层。function initPopUp() {
        // Add the HTML to the body
        theBody = document.getElementsByTagName('BODY')[0];
        popmask = document.createElement('div');
        popmask.id = 'popupMask';
        popcont = document.createElement('div');
        popcont.id = 'popupContainer';
        popcont.innerHTML = '' +
            '<DIV class="x-window x-window-plain x-window-dlg" id="ext-comp-1001" style="DISPLAY: block; Z-INDEX: 9003;  VISIBILITY: visible;WIDTH: 300px; POSITION: absolute; TOP: 116px;LEFT: 354px;">' +
                '<DIV class="x-window-tl">' +
                    '<DIV class="x-window-tr">' +
                        '<DIV class="x-window-tc">' +
                            '<DIV class="x-window-header x-unselectable x-window-draggable" id="ext-gen15" style="MozUserSelect: none; KhtmlUserSelect: none" unselectable="on">' +
                                '<DIV class="x-tool x-tool-close " id="ext-gen59" onclick="hidePopWin(false);" style="DISPLAY: block">' +
                                    '&nbsp;' +
                                '</DIV>' +
                                '<SPAN class="x-window-header-text" id="popupTitle">' +
                                    'Address' +
                                '</SPAN>' +
                            '</DIV>' +
                        '</DIV>' +
                    '</DIV>' +
                '</DIV>' +
                '<DIV class="x-window-bwrap" id="ext-gen16">' +
                    '<DIV class="x-window-ml">' +
                        '<DIV class="x-window-mr">' +
                            '<DIV class="x-window-mc">' +
    '<!-- Start-->' +
    '<div id="popBodyBox">' +
    '</div>' +
    '<!-- End-->' +
                            '</DIV>' +
                        '</DIV>' +
                    '</DIV>' +
                    '<DIV class="x-window-bl">' +
                        '<DIV class="x-window-br">' +
                            '<DIV class="x-window-bc">' +
                                '<DIV class="x-window-footer" id="ext-gen18"></DIV>' +
                            '</DIV>' +
                        '</DIV>' +
                    '</DIV>' +
                '</DIV>' +
            '</DIV>'    theBody.appendChild(popmask);
        theBody.appendChild(popcont);    gPopupMask = document.getElementById("popupMask");
        gPopupContainer = document.getElementById("ext-comp-1001");
        gShadowBox = document.getElementById("ShadowBox");    gpopBodyBox = document.getElementById("popBodyBox");    // check to see if this is IE version 6 or lower. hide select boxes if so
        // maybe they'll fix this in version 7?
        var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
        if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
            gHideSelects = true;
        }
        gPopupContainer.style.display = "none";
        // Add onclick handlers to 'a' elements of class submodal or submodal-width-heigh    iframestring = '<iframe src="" style="width:100%;height:100%;background-color:transparent;display:none;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe><iframe src="" style="width:100%;height:100%;background-color:transparent;display:none;" scrolling="no" frameborder="0" allowtransparency="true" id="popupFrameno" name="popupFrameno" width="100%" height="100%"></iframe>';
        gpopBodyBox.innerHTML = iframestring;
    }现在想在B.aspx页面执行
    Button按钮完后再通过RegisterStartupScript关掉遮盖层。function hidePopWin(callReturnFunc) {
        if (typeof (hidePopWined) == "function") { hidePopWined(); }    gPopupIsShown = false;
        var theBody = document.getElementsByTagName("BODY")[0];
        theBody.style.overflow = "";
        restoreTabIndexes();
        if (gPopupMask == null) {
            return;
        }
        gPopupMask.style.display = "none";
        gPopupContainer.style.display = "none";
        if (callReturnFunc == true && gReturnFunc != null) {
            //alert(window.frames["popupFrame"].returnVal);
            gReturnFunc(window.frames[gDefaultFrameID].returnVal);
        }
        gPopFrame.src = gDefaultLogin;
        gPopFrameno.src = gDefaultLogin;
        //gpopBodyBox.innerHTML = "";
        // display all select boxes
        if (gHideSelects == true) {
            displaySelectBoxes();
        }
    }
      

  5.   

    //]]>
    </script>
    <script type= text/javascript defer=defer>$(document).ready(function(){hidePopWinSc(false)})</script></form>
    </body>
    </html>
    通过RegisterStartupScript在后台生成的还是gPopupMask=null。