Created
January 18, 2022 07:50
-
-
Save interduo/b27f79a82f636c73793e24f1fe837fda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this works only in FF | |
<html> | |
<input type="file" > | |
<object id="view" type="application/pdf" width="100%" height="100%"></object> | |
</html> | |
<script type="text/javascript"> | |
var fileInput = document.querySelector('input'); | |
var elem = document.querySelector('object'); | |
fileInput.onchange = () => { | |
var file = fileInput.files[0]; | |
var objUrl = window.URL.createObjectURL(file); | |
elem.setAttribute('data', objUrl); | |
URL.revokeObjectURL(objUrl); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment