<script type="text/javascript">
    function aaa() {
        var str = window.showModalDialog("haealthrecord/PersonalSelect.aspx?t=" + new Date().valueOf(), window, "dialogWidth=750px;dialogHeight=380px;");
        if (str != undefined) {
            var str2 = window.showModalDialog("ConditionExaminationSelect.aspx?t=" + new Date().valueOf(), window, "dialogWidth=750px;dialogHeight=380px;");
            if (str2 != undefined) {
                document.getElementById("hfPID").value = str;
                document.getElementById("hfID").value = str2;
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
</script>  如上代码,我想点击一个按钮后先弹出一个对话框叫我选择用户,选择了之后再弹出第二个对话框选择日期,二个对话框都是模态对话框的,代码应该如上面的代码所示的,但是我在IE中运行的时候弹出第一个对话框选择用户了,IE就提示无法访问了,第二个模态对话框弹出来的,请问这个我应该怎么改?

解决方案 »

  1.   

    应该是你的参数没有传过来,如果str要获取值的话,需在 haealthrecord/PersonalSelect.aspx这个页面中有回传值,即:window.returnValue="";这样str才会有值 
      

  2.   

    先alert下第一个的返回值,看看是否正确.
      

  3.   

    代码是肯定正确的。。要不这样。。下面的代码在IE下执行也会出错的:
    <script type="text/javascript">
        function aaa() {
            var str = window.showModalDialog("haealthrecord/PersonalSelect.aspx?t=" + new Date().valueOf(), window, "dialogWidth=750px;dialogHeight=380px;");  
            var str2 = window.showModalDialog("ConditionExaminationSelect.aspx?t=" + new Date().valueOf(), window, "dialogWidth=750px;dialogHeight=380px;");
         
        }
    </script>
    上面的代码执行也会出错的,IE出出现“访问拒绝”的错误,我上网查了一下,可能是因为IE7以后为了提高安全性,像showModalDialog的这种方法只允许由用户主动调用,这样上面的第一个show是我点击按钮后执行的,但是第二个sow是由代码调用的。。这样就导致访问出错的,不知道有什么方法可以解决啊