function buildElement(tagName, props) {
var element = document.createElement(tagName);
for (var propName in props) element[propName] = props[propName];
return element;
}
function submit(link, props, callback) {
var iframe = buildElement('iframe'),
iframeDoc = iframe.contentDocument || iframe.contentWindow.document,
form = buildElement('form', {
method: 'post',
action: link
});
for (var propName in props) form.appendChild(
buildElement('input', {
type: 'hidden',
name: propName,
value: props[propName]
})
);
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframeDoc.body.appendChild(form);
form.submit();
if (typeof callback === "function") {
iframe.onload = function() {
callback((this.contentDocument || this.contentWindow.document).body.innerHTML);
document.body.removeChild(iframe);
};
} else {
document.body.removeChild(iframe);
}
}
btn.onclick = function() {
submit('php/print_pdf.php', {
target: 'print_pdf'
});
submit('php/print_rtf.php', {
target: 'print_rtf'
});
};
сам не пробовал, но походу должно работать