I'm very new to coding and need to have a button that prints the object only. I have looked at so many other questions but cannot find a solution that works for me. This is my code so far, but it only works on IE. I need it to work on other browsers especially Chrome and Firefox. Any ideas please?
<object data="folder/thedoc.pdf" id="myDoc" type="application/pdf" width="300" height="200">
alt : <a href="folder/thedoc.pdf">thedoc.pdf</a>
</object>
<script>
function printDocument() {
var x = document.getElementById("myDoc");
x.print();
}
</script>
<button onclick="printDocument()">Print</button>