您如何使用in模拟 Form 的'POST'
操作?(即发布数据并在新选项卡中打开目标页面)target="_blank"
XMLHttpRequest
问问题
2048 次
1 回答
2
gBrowser
开箱即用地提供此功能。
var dataStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
dataStream.data = "foo=bar&alpha=beta"; // make sure the values are properly encoded with encodeURIComponent
var postStream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci.nsIMIMEInputStream);
postStream.addHeader("Content-Type", "application/x-www-form-urlencoded");
postStream.addContentLength = true;
postStream.setData(dataStream);
gBrowser.loadOneTab("http://www.example.com/", {inBackground: false, postData: postStream});
于 2014-07-16T17:19:24.270 回答