-1

更新ボタンをクリックしたときにウィンドウを表示したいのですが、このウィンドウは3秒間表示されたままになり、その後閉じた後、更新アクションの実行が自動的に終了します。これは私のコードですが、動作しません

my $cScript = qq{

\$(document).ready(function(){
    var w;
    function closeWindow(){ 
        setTimeout(function() {
           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($cScript);
 }

HTML フォーム:

 $cInput_form .= $q->image_button({
      -src =>  '/media/images/save_1.png',
      -class=>'btn btn-primary btn-large',
      -title => 'update', 
      -name => 'Update', 
      -value => $row_id,
      -onclick => "createWindow()"
});



print $q->fieldset ({-class => "ui-widget ui-widget-content"}, $cInput_form);

問題はどこだ?

4

1 に答える 1

2

デモ: jsFiddle

JS:

var w;

createWindow();

function closeWindow() {
    setTimeout(function () {
        w.close();
    }, 3000);
}

function createWindow() {
    //create the popup window.
    var htmlText = "<p>Updating...</p>";
    w = window.open("", "", 'width=200,height=100');
    $(w.document.body).html(htmlText);
    closeWindow();
};
于 2013-07-28T19:48:19.950 に答える