Get the tag "a" from iframe

81 views Asked by At

This is my code, i need to get the tag "a" from the iframe but when i get it i get an empty array like this: Empty array

const frame = this.pdfViewer.iframe.nativeElement
    const frameArray = frame.contentWindow.document.getElementsByClassName("page")[this.pdfViewer.page - 1].getElementsByTagName("a")
    console.log(frameArray)

but when i open it i have this: This is the "a" on my array. How can i get the tags?

1

There are 1 answers

1
Zeeshan Shaheen On

Try this

const frame = this.pdfViewer.iframe.nativeElement const frameArray = frame.contentWindow.document.getElementsByClassName("page")[this.pdfViewer.page - 1] console.log(frameArray.getElementsByTagName("a"))