Try to search your question here, if you can't find : Ask Any Question Now ?

How to open a url in new window and then trigger ctrl + p (print)?

HomeCategory: stackoverflowHow to open a url in new window and then trigger ctrl + p (print)?
Avatarrupesh asked 3 months ago

I have iframe within a div and have a print button, on clicking print I want to open a new tab and trigger print action for the url being shown in iframe.
I am using Angular 7.

Solutions I tried so far:

How to open a link new tab with print command?


      <iframe #iframe [src]="url"  width="100%" id='event-print-iframe'
          name="targetframe" allowTransparency="true"   >

<button (click)='print()'>Print</button>


 import {
} from '@angular/core';
 @ViewChild('iframe') iframe: ElementRef;
        let content = this.url;
        let doc =  this.iframe.nativeElement.contentDocument || this.iframe.nativeElement.contentWindow;;


Solution From iframe inside angular2 component, Property ‘contentWindow’ does not exist on type ‘HTMLElement’?

Error using above solution:

ERROR DOMException: Blocked a frame with origin
http://localhost:4200” from accessing a cross-origin frame.

I have a url and I just want to open it in new tab and print without clicking Ctrl+p

Thanks in advance for helping!

1 Answers
Best Answer
AvatarFernando answered 3 months ago
Your Answer

4 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By :