2013-07-28 167 views
0

我想在点击'更新'按钮之后显示5秒钟的警报消息,然后执行更新操作。显示5秒钟的警报消息

my $cFunction = qq{ 
\$(document).ready(function(){ 
    var w; 
    function closeWindow(){ 
    setTimeout("w.close();", 3000); 
    } 

    function createWindow(){ 
    //create the popup window. 

    w=window.open("","",'width=200,height=100'); 

    // put something into the popup window 
    try{w.document.write('<html><head></head><body><p>Updating...</p></body> <html>')}catch(err){ 
    //handle error here 
    } 
    closeWindow(); 
    } 
} 
}; 

print $q->script($cFunction); 
<--html form---> 

    $cInput_form .= $q->image_button({-src => '/media/images/save_1.png',-class => 'upd',-title => 'update', -name =>'Update', -value => $row_id, -onclick => 'createWindow()'}); 
    print $q->fieldset ({-class => "ui-widget ui-widget-content"}, $cInput_form); 

但这是行不通的。为什么?

+1

请试试这个:'setTimeout(timeout_trigger,5000);' – Cherniv

+0

你想让警报消息停留5秒,然后隐藏自己吗? – higuaro

+0

它仍然不显示消息 – Armida

回答

0

我的建议不会解决你的代码。

但是如果您不知道:要显示/刷新通知或警告消息,可以使用各种javascript库。

“javascript通知库”搜索将显示许多结果。

我已经使用TOASTR,它工作得很好。这里是demo page

+0

这是否会阻止更新操作?因为我想要做的事情是:“更新...”,并在3秒后消息丢失和更新执行 – Armida

+0

不,它不。但它会按照一行中的配置闪烁3秒或5秒的信息。 – swapneel

+0

如何显示停留几秒钟并阻止某些操作的警报窗口。你知道一个方法吗? – Armida