Skip to content
Advertisement

how to get the URL of a PDF file from a google chrome extension

Last year I developed a google extension that worked on PDF files. I used the following function in order to get the URL of the PDF file:

JavaScript

Now, the latest version of Google Chrome does not provide the src attribue anymore.

JavaScript

How can I get the URL of the PDF file with the latest version of Google Chrome?

Advertisement

Answer

Apparently PDF is now viewed through an internal chrome extension chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/.

Aside from using window.location.href you can use document.querySelector("embed").baseURI

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement