How to open PDFs in Iframe Onclick the Button
How to open PDFs in Iframe Onclick the Button –
How to open a PDF file in an Iframe
- Example of HTML file given as bellow –
- How to load PDFs in Iframe Onclick event in java script the Button
- Click on button “Click here to open PDF” to open PDF in iframe.
- placeFrame.src define path of PDF File.
<html>
<head>
</head>
<body>
<p align="center"><iframe id="iFrameLocationId" style="display:none" width="650" height="350"></iframe></p>
<p align="center"><input type="button" value="Click here to open PDF" onclick = "openPdfIframe()"/></p>
<script type="text/javascript">
function openPdfIframe(){
var placeFrame = document.getElementById("iFrameLocationId");
placeFrame.style.display="block";
placeFrame.src = "dummy_pdf.pdf"; // pdf file location
}
</script>
</body>

