function closeBtnClick(){ 
        var msgContent = document.getElementById("lblMessage").innerText; 
        if (msgContent == XXX1) 
        { 
            window.opener.doPostBack(url1,''); 
        } 
        else if(msgContent == XXX2) 
        { 
            window.opener.location.href = url2; 
        } 
        window.close(); 
    } 

解决方案 »

  1.   

    字符串都要加""否则程序会认为是变量
    javascript中的变量定义都是var 没有string之类的
    lable实际上是个DIV 
    javascript获取INPUT以外的值的方法基本上是innerText
    javascript获取INPUT值的方法是value
      

  2.   

    谢谢。不过 if (msgContent == PRConst.MSG_SUCCESS_SAVE)
    为啥报PRConst没有定义的错阿。是不是写法不错啊
      

  3.   

    我刚才把代码稍微有些改动。没想到上面问题解决了,还有问题源代码我这样写的    function closeBtnClick(){
            var msgContent = document.getElementById("lblMessage").innerText;
            if (msgContent == PRConst.MSG_SUCCESS_SAVE)
            {
               window.opener.parent.window.focus();
                window.opener.doPostBack('<%=PRConst.EVENT_TARGET_FINISH%>','');
            }
            else if(msgContent == PRConst.SUCCESS_APPL)
            {
                window.opener.location.href = "<%=PRConst.FORM_MAIN_PORTAL_APPL%>";
            }
            window.close();
        }帮忙指正,你好厉害,一眼就看出来问题出在那里,佩服
      

  4.   

    PRConst你定义了吗?
    javascript没有PRConst这个对象
      

  5.   

    是挺初级的,我基本上没怎么用过javascript。PRConst怎么在javaScript里面定义阿,我这个是公用变量啊,定义过的阿
      

  6.   

    我试验过的
    放在window.opener.location.href = " <%=PRConst.FORM_MAIN_PORTAL_APPL%>"; 就不报PRConst没有定义的错误放在if(msgContent == PRConst.MSG_SUCCESS_APPL)里才报错,估计是写法的问题请帮忙,谢谢
      

  7.   

    放在双引号内 表示是字符串msgContent == PRConst.MSG_SUCCESS_APPL 表示是某个对象的属性 如果不存该对象或存在对象不存相关属性 当然会报错了
      

  8.   

    PRConst.MSG_SUCCESS_APPL 存在阿~
      

  9.   

    javascript里存在?? 你定义的???
      

  10.   

    应该是服务器端定义的,需要用<%%> function closeBtnClick(){ 
            var msgContent = document.getElementById("lblMessage").innerText; 
            if (msgContent == "<%=PRConst.MSG_SUCCESS_SAVE%>") //=====
            { 
              window.opener.parent.window.focus(); 
                window.opener.doPostBack(' <%=PRConst.EVENT_TARGET_FINISH%>',''); 
            } 
            else if(msgContent == "<%=PRConst.SUCCESS_APPL%>") //========= 
            { 
                window.opener.location.href = " <%=PRConst.FORM_MAIN_PORTAL_APPL%>"; 
            } 
            window.close(); 
        } 
      

  11.   

    设置一个隐藏空件
    <input type="hide" id="hidValue" value="<%=PRConst.FORM_MAIN_PORTAL_APPL%>">
    获取控件值:var strValue = document.getElementById("hidValue").value;
    "曲线救国"
      

  12.   


    这个方法和<%%>效果是一样的。
      

  13.   

    但是并没有找到正确的画面
    ---
    什么意思
    检查生成的html代码看生成的客户端js代码对没有