How to embed a PDF without using JavaScript
PDFs can be embedded into HTML pages without using JavaScript. Below are four examples of the most common techniques.
Note: these examples work in most modern desktop browsers, but results will vary in older desktop browsers and mobile browsers. None of these examples work properly on mobile, including iOS.
<embed>
The <embed>
element became an official part of the HTML specification with HTML5. All HTML5-compliant browsers—all 'modern' browsers—officially support the <embed>
element. Older browsers also offer surprisingly robust (though sometimes unofficial) support for <embed>
. Unfortunately, when used in static markup, the <embed>
element doesn't provide a mechanism for fallback content. If the browser doesn't support PDF embedding, which still happens frequently with browsers on mobile devices, the end-user will see nothing.
<embed src="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%" />