I have this working code:
$.post("./php/acc_con_def.php",
{contratto:contratto,vers:vers,scelta:"nuovo"},
function(data){
window.open("./temp/accettazione.pdf")
});
I'm tring to use this code to open pdf in开发者_Python百科 a div but it doesnt work here is my used code:
$.post("./php/acc_con_def.php",
{contratto:contratto,vers:vers,scelta:"nuovo"},
function(data){
$("#hideShow").show("slow");
function embedPDF(){
var myPDF = new PDFObject({
url: './temp/accettazione.pdf'
}).embed('hideShow');
}
window.onload = embedPDF;
});
try this:
$.post("./php/acc_con_def.php", {contratto:contratto,vers:vers,scelta:"nuovo"},
function(data) {
$("#hideShow").show("slow");
var myPDF = new PDFObject({ url: './temp/accettazione.pdf' }).embed('hideShow');
}
);
if you want to do when you finish loading the page, you must do so:
$(function() {
$.post("./php/acc_con_def.php", {contratto:contratto,vers:vers,scelta:"nuovo"},
function(data) {
$("#hideShow").show("slow");
var myPDF = new PDFObject({ url: './temp/accettazione.pdf' }).embed('hideShow');
}
);
});
the problem in your code is that after making the post, the event "load" of "window" ended.
EDIT
try this code to see if your browser is working well:
$("#hideShow").show();
$.post("./php/acc_con_def.php", {contratto:contratto,vers:vers,scelta:"nuovo"},
function(data) {
if ($.browser.msie)
$("#hideShow").append('<div><object width="100%" height="100%" classid="CLSID:CA8A9780-280D-11CF-A24D-444553540000" data="./temp/accettazione.pdf#" type="application/pdf"/></div>');
else
$("#hideShow").append('<div><object type="application/pdf" data="./temp/accettazione.pdf#" width="100%" height="100%"></object></div>');
}
);
HTML for Test
first create the file './temp/accettazione.pdf
'
<!DOCTYPE html>
<html>
<head></head>
<body>
<div>for IE</div>
<div><object width="100%" height="100%" classid="CLSID:CA8A9780-280D-11CF-A24D-444553540000" data="./temp/accettazione.pdf#" type="application/pdf"/></div>
<br /><br />
<div>for other</div>
<div><object type="application/pdf" data="./temp/accettazione.pdf#" width="100%" height="100%"></object></div>
</body>
</html>
精彩评论