BlogJava 联系 聚合 管理  

Blog Stats

文章分类

收藏夹

随笔档案

文章档案

Java相關技術


kait


今天看到有篇文章寫到 windows.open 可以post方式傳遞參數,就趕緊照作看看,結果是可行的,
感謝撰寫這篇文章的作者~

/**
 * window.open with post method
 */
function openWindowWithPost(url, name, keys, values) {
    var newWindow = window.open(url, name);
    if (!newWindow){
        return false;
    }
    
    var html = "";
    html += "<html><head></head><body><form id='formid' method='post' action='"    + url + "'>";
    if (keys && values && (keys.length == values.length)){
        for ( var i = 0; i < keys.length; i++){
            html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
        }
    }
    html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
    newWindow.document.write(html);
    return newWindow;
}

詳細參考網址:http://www.dotblogs.com.tw/puma/archive/2008/09/03/5288.aspx
posted on 2011-05-27 00:20 小天 阅读(5645) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: