Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style>
- body {
- margin: 0;
- overflow: hidden;
- }
- iframe {
- overflow: auto;
- border: none;
- width: 100%;
- height: 100%;
- }
- </style>
- </head>
- <body>
- <div id="pdf">
- <iframe src="" type="application/pdf">
- </iframe>
- </div>
- <script>
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "https://cors-anywhere.herokuapp.com/https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", true);
- xhr.responseType = "blob";
- xhr.onload = function (e) {
- if (this.status === 200) {
- var file = window.URL.createObjectURL(this.response);
- document.querySelector("#pdf>iframe").src = file;
- }
- };
- xhr.send();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement