Open a URL in page with JavaScript

Hey there, I currently have a script that opens a url from selection. I would then like to select a PDF document in the page and open it in the same page.

I've produced this code but it doesn't seem to work?

let pdf_src = window.document.getElementById('pdf').src, name="_parent")


I suspect it is the "window" parameter that JavaScript doesn't know how to search?