JavaScript的confrmation中,执行$如果点击仅次于C $空调yes [英] javascript confrmation box, executing code behind only if clicked yes

查看:118
本文介绍了JavaScript的confrmation中,执行$如果点击仅次于C $空调yes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的如下previous问题.. 如何在关闭弹出窗口刷新父页面?

我试过事物的组合,但不能使它工作..有时候code后面执行不管我选择了IE浏览器。 是,否或x(收),有时..喜欢用下面的code的情况下..永远不会不管我点击了什么选项。

执行后面的code

 < ASP:按钮的ID =btnAccept=服务器文本=接受的OnClientClick =返回刷新()的风格=HEIGHT:19px;背景:# C0003B;颜色:白色;/> &安培; NBSP;< ASP:按钮的ID =btnReject=服务器文本=拒绝的OnClientClick =刷新()的风格=HEIGHT:19px;背景:#C0003B;颜色:白色;/&GT ;
< / DIV>
   <脚本类型=文/ JavaScript的>       功能刷新(){
           VAR myBoolean =新布尔();
           myBoolean =确认(你确定吗?');           如果(myBoolean){               window.onunload = refreshParent;               功能refreshParent(){
                   window.opener.location.reload();
                   返回true;
               }
           }
           其他{返回false;}
       }
< / SCRIPT>


解决方案

有一个在这个

 函数刷新(){
    VAR确认=确认(你确定吗?');    如果(确认){
        window.onunload = refreshParent;
        返回true;
    }其他{
        返回false;
    }
}功能refreshParent(){
    window.opener.location.reload();
}

This is following my previous question.. How to reload parent page on closing PopUp window?

I tried a combination of things but could not make it work.. Sometimes the code behind executes no matter what i chose ie. "yes" , "no" or x(to close) , sometimes.. like the case with the following code.. the code behind never gets executed no matter what option i click..

      <asp:Button ID="btnAccept" runat="server" Text="Accept"  OnClientClick="return Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white; " /> &nbsp;<asp:Button ID="btnReject" runat="server" Text="Reject" OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white;"/>


</div>
   <script type="text/javascript">

       function Refresh() {
           var myBoolean = new Boolean();
           myBoolean = confirm('Are you sure?');

           if (myBoolean) {

               window.onunload = refreshParent;

               function refreshParent() {    
                   window.opener.location.reload();
                   return true;
               }
           }
           else {return false;}
       }
</script>

解决方案

Have a look at this

function Refresh() {
    var confirmed = confirm('Are you sure?');

    if (confirmed) {
        window.onunload = refreshParent;
        return true;
    } else {
        return false;
    }
}

function refreshParent() {
    window.opener.location.reload();
}

这篇关于JavaScript的confrmation中,执行$如果点击仅次于C $空调yes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆