Okay, in my first jump into AJAX-like behavior...
I'm wanting to load a div with a pdf based on a user click on a link. If the user clicks on a second link, the div should be overwritten with the new pdf.
So I figured on testing it with something like:
<script>
function showPdf()
{
var pdfDiv = document.getElementById("pdfDiv");
pdfDiv.innerHTML='<object type="application/pdf" data="my.pdf" width="500" height="650" ></object>';
}
</script>
<div id="pdfDiv"></div>
This, however, does not work.
I'm guessing I'm probably setting the innerHTML, but it's not actually fetching the file. I figure I need some AJAXy knowledge to force that new request after the page has loaded. Can someone point me to the right object to start exploring?
You could try and use something like this...
I'd try something easier: use Google PDF Viewer service. You just have to create an iframe and change its src:
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With