我创建了一个脚本发布请求数据并打开新页面。
您是否知道如何将其作为新标签或新窗口打开?我不想将目标设置为_blank,因为我希望人们也可以打开我的网站。
如何阻止弹出窗口打开新窗口。
脚本
function printPDF(task) {
var fdata = {
"record": "'.$this->bean->id.'"
};
// var params = jQuery.param(fdata);
$.ajax({
type: "post",
data: fdata,
dataType: "json",
url: "index.php?module=ginvo_client_invoice&action=printinvoice",
error: function(resp) {},
success: function(resp) {
var invoicedetails = JSON.stringify(resp);
// console.log(resp);
var param = {
result: invoicedetails
};
post("custom/clientinvoice.php", param);
}
});
function post(path, params, method) {
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
form.setAttribute("target", "_blank");
for (var key in params) {
if (params.hasOwnProperty(key)) {
var inputField = document.createElement("input");
inputField.type = "hidden";
inputField.name = key;
inputField.value = params[key];
form.appendChild(inputField);
}
}
document.body.appendChild(form);
window.open(path, "_blank");
form.submit();
document.body.removeChild(form);
}
}