Here's the problem, I'm currently working on a T&Cs page that loads a PDF file inside an iFrame. As part of the validation I'm writing to confirm that the PDF was correctly loaded, I'm checking the URL and the content-type. Now this works without issue in Chrome and Edge, but does not work in Firefox. The error I'm getting is as follows:
Uncaught DOMException: Permission denied to access property "document" on cross-origin object
My code looks something like this:
onIFrameLoad = function () {
var url = new URL($("#myIFrame").contents().get(0).location.href);
}
The project that this is apart of is an ASP.NET MVC app w/ jQuery 1.12.4. We also have jQuery 3.4.1, but that is not loaded at this time. Also the PDFs are being served from the same host as the page that hosts the iFrame in it.
Like I said this code works in Edge and Chrome, but it does not in Firefox. I've tried several "solutions" that I've found like the "x-frame-options: SAMEORIGIN" header on both webpages to no avail.
Has anyone figured out how to get this to work in Firefox and/or have another way to determine if a PDF has been loaded in an iFrame in Firefox?
Thanks in advance.