I have a mind-numbingly dull task that I'm trying to speed up by writing some PHP scripts that run on my localhost, fetch remote web pages, and distill certain info. Part of the process that I'm trying to expedite is to show some data extracted from an article abstract along with a PDF of the article. My script fetches the html from the abstract, looks for the values I'm after and shows them to me and I'd like to go ahead and show the PDF in a frame or iframe. It may sound trivial to click one more <a> link to open the PDF, but if I could save that one click, it will result in a great deal of time saved over the life of this project.

The problem I have is that firefox blocks any attempt to show a remote PDF in an iframe. I've tried setting it as the iframe src attribute, i've tried loading it via Javascript either on page load or in response to user clicks, I've tried a meta redirect and nothing seems to work. Firefox always says:

firefox wrote:

Blocked loading mixed active content "http://example.com/path/to/remote/file.pdf"
Line 0

Is there no way to display both my distilled information and the pdf in a single window?

    You should be using

    <object type="application/pdf" data="url"></object>
    

    Possibly specifying width and height too since those will default to small values.

      Thanks for your suggestion, but I tried this:

      <object type="application/pdf" data="http://example.com/pdf?res=blahblahblah" style="width:100%; height:800px;"></object>

      and it doesn't even result in a request to the remote site or a "blocked content" message.

        Do you have this live somewhere we could view? Also, which browser are you using?

        You might have to include an <embed> tag inside the <object> for maximum browser compatibility. However, using Chrome, the <object>-only approach above appears to work just fine for me.

          Did you also inspect the actual requests involved from your browser? Object works in both Chrome and FF. It does of course still require the browser to have capabilities for displaying pdfs. Else you'd need fallback content or nothing will show.

            I'm using firefox on an Ubuntu workstation. I did inspect (using firebug) the requests sent and there appears to be only the request for the page itself -- the <object> tag doesn't result in any request at all. I've had no problem displaying these PDFs when accessing them directly in firefox.

            After some tinkering, I have isolated the problem. The page in which I want to show this pdf is hosted via HTTPS and the pdf link is not. It works fine when page is not hosted via HTTPS. In retrospect, this is not surprising that the browser would be annoying about HTTPS hosted pages. Kind of a relief actually.

              Write a Reply...