Print function working on desktop but not mobile

Viewed 36

So I have written a function to print just a certain section of a website the restore the site to the full page. This function is working properly on desktop and in the dev tools but when I open the page on my iPhone it wants to print the entire website.

function printContent(el) {
  var restorepage = document.body.innerHTML;
  var printcontent = document.getElementById(el).innerHTML;
  document.body.innerHTML = printcontent;
  window.print();
  document.body.innerHTML = restorepage;
}
<button class="printButton" onclick="printContent('recipe1')"><img src="img/main/printer.png" alt=""></button>

Also, is there some js I can add to return to the exact spot on the page when the print box is closed?

0 Answers
Related