如何在检查确认确定后淡入div

时间:2014-09-13 09:49:32

标签: javascript jquery

JS

    function CheckFedderalTimeStatus(){
    var answer = confirm('Federal law restricts sending of mobile text messages between 9PM and 8AM of recipient`s local time. If you believe that the nature of your message does not fall under this restriction (e.g. emergency alert), please click OK to apply for an exception.');

    if(answer){
        $("#inline2").fadeIn(300);
        $(".overlay-fixed").fadeIn(300);
        $(".fancybox-opened").fadeIn(300);
        return false;
    } else {
        window.location = "sendmsg.php";
        return false;
    }
}

HTML

<a href="#" onclick="CheckFedderalTimeStatus()">fade In </a>
<div id="inline2" style="width:650px;display: none; font-size:14px; overflow:scroll"> hello </div>

我只想在弹出框中打开此框,单击确认框上的确定和取消按钮上的页面刷新

2 个答案:

答案 0 :(得分:0)

功能CheckFedderalTimeStatus()在全球范围内不可用。

以下是修改后的代码:

JS

<script>
 window.CheckFedderalTimeStatus = function(){
      var answer = confirm('Federal law restricts sending of mobile text messages between 9PM
and 8AM of recipient`s local time. If you believe that the nature of your message does
not fall under this restriction (e.g. emergency alert), please click OK to apply for an
exception.');

if(answer){
   $("#inline2").fadeIn(300);
   $(".overlay-fixed").fadeIn(300);
   $(".fancybox-opened").fadeIn(300);
   return false;
}
else {
  location.reload(); // reload the page
  //window.location = "sendmsg.php";
  return false;
 }
}
</script>

以下是演示:http://jsfiddle.net/z9cry2tp/

答案 1 :(得分:0)

我认为如果您希望保持当前页面的原样,那么您只需return false部分中的else

else {
    location.reload(); // use this if you want to reload page anyway.
    return false;
}

对于if部分,我能想到的是你想在弹出框中显示'#inline2'元素。 PLEASE SEE THE EXAMPLE。我想这就是你想要的?