2014-09-13 49 views
0

JS如何在DIV褪色的檢查確認後確定

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> 

我只是想打開彈出框該框上點擊確認框和頁面行刷新取消按鈕

+0

請澄清您的需求,以及您想要在彈出框中打開此框是什麼意思? – VPK 2014-09-13 09:57:38

+0

@VaibhavKatole我想在彈出框中打開此框 – 2014-09-13 10:06:03

+0

單擊取消按鈕時是否要重新加載當前頁面? – VPK 2014-09-13 10:11:20

回答

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/

+0

你的小提琴顯示控制檯錯誤。 '未捕獲的ReferenceError:CheckFedderalTimeStatus未定義'請檢查。 – VPK 2014-09-13 10:09:58

+0

@VaibhavKatole:哦,我沒有看到從多個瀏覽器檢查錯誤。檢查這一個http://jsfiddle.net/z9cry2tp/3/ – way2vin 2014-09-13 10:16:41

0

,如果你想留你當前頁面,因爲它是我想,那麼你可以簡單return false從您的else部分,

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

對於if部分,我可以弄清楚的是,您想要在彈出框中顯示'#inline2'元素。 PLEASE SEE THE EXAMPLE。我猜這就是你想要的?