I am using the following to POST information, and when I am creating the form element, I get an exception: "Permission denied".
var newWindow = window.open('', '_blank', 'alwaysRaised=yes,toolbars=no, menubar=no, location=no, scrollbars=yes, resizable=yes, status=yes,left=10000, top=10000, width=10, height=10, visible=none', '');
var tempFormElement = newWindow.document.createElement('form');
tempFormElement.method = 'post';
tempFormElement.action = urlToOpen;
var tempInputElement;
tempInputElement = newWindow.document.createElement('input');
tempInputElement.setAttribute('TPLInfo', JSON.stringify(linkageInfo));
tempFormElement.appendChild(tempInputElement);
tempFormElement.submit();
newWindow.document.body.removeChild(tempFormElement);
newWindow.close();
Please suggest.
So I suggest - if you can:
Ajax using jQuery
$.post(urlToOpen,{"TPLInfo":JSON.stringify(linkageInfo)});
or if not on same domain (plain JS) :
var newWindow;
var urlToOpen = "....";
function perform() {
if (!newWindow) {
alert("Sorry, you must allow popups");
return;
}
var tempFormElement = newWindow.document.createElement('form');
tempFormElement.method = 'post';
tempFormElement.action = urlToOpen;
var tempInputElement;
tempInputElement = newWindow.document.createElement('input');
tempInputElement.setAttribute("name","TPLInfo");
tempInputElement.value = JSON.stringify({"a":"1"});
tempFormElement.appendChild(tempInputElement);
newWindow.document.body.appendChild(tempFormElement);
tempFormElement.submit();
}
window.onload=function() {
document.getElementById("but").onclick=function() {
// var parms = "alwaysRaised=yes,toolbars=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes,left=10000,top=10000,width=10,height=10,visible=none";
// valid parms, yes I know you want to hide and close but nope.
var parms = "scrollbars,resizable,status,left=10000,top=10000,width=100,height=100";
newWindow = window.open('', '_blank',parms);
setTimeout(perform,500); // give IE time to get over opening
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.