Jump to content


Photo

Printing to printer on desktop/laptop - and IDE bug


  • Please log in to reply
3 replies to this topic

#1 Czar

Czar
  • Members
  • 153 posts

Posted 25 August 2017 - 12:08 AM

Hi all,

I figured out that I can print using

asm
window.print();
end;

However, I actually just want to print the contents of an Iframe "W3IFrameHTMLElement1". But I have not been able to get that working. I tried a number of javascript solutions but none worked.


e.g,

asm
document.getElementsByName("W3IFrameHTMLElement1").print();
end;

#2 Nico Wouterse

Nico Wouterse
  • Moderators
  • 250 posts
  • LocationAustralia

Posted 25 August 2017 - 04:04 AM

I think solutions in this link https://stackoverflo...ut-not-the-page(using innerhtml) will do the trick
  • Czar likes this
Nico Wouterse

#3 Czar

Czar
  • Members
  • 153 posts

Posted 25 August 2017 - 05:40 AM

Excellent, I got this working

var printContents = W3DIVHtmlElement1.InnerHTML;
asm
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;

window.print();
document.body.innerHTML = originalContents;
end;

#4 Igor Savkic

Igor Savkic
  • Members
  • 185 posts

Posted 25 August 2017 - 06:02 AM

> Excellent, I got this working
> var originalContents = document.body.innerHTML;
> document.body.innerHTML = printContents;
> window.print();
> document.body.innerHTML = originalContents;

Just an idea, better approach (note that I don't know if it would work) would be to create a new window, set it's document body, print and then delete that Temp window. Thay way you do not messup with active document body.
  • Czar and Nico Wouterse like this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users