flex-users / flex-iframe

IFrame component for Flex applications.
github.com/flex-users/flex-iframe
120 stars 63 forks source link

loadIndicatorClass is not working with pdf source #98

Open nicoulaj opened 13 years ago

nicoulaj commented 13 years ago

Originally filed by luanviet...@gmail.com on 2009-10-12T21:33:06

What steps will reproduce the problem?

  1. Import the IFrameWithLoadIndicator example project
  2. Change the source on both panel to http://www.mitpressjournals.org/doi/pdfplus/10.1162/0891201053630264 Note that it can be any url to a pdf content.
  3. Run the example.

What is the expected output? What do you see instead? Expect both panel to load the pdf as they did with http://www.facebook.com But only the top panel load the pdf. The bottom panel (has loadClassIndicator) spins the Loading... forever.

What version of the product are you using? On what operating system? Trunk as of today Oct 12, 2009. Windows XP.

Please provide any additional information below. Flex builder 3.0.2 IE7 and Firefox

nicoulaj commented 13 years ago

Updated by primo...@gmail.com on 2009-10-13T08:44:52

Is your browser configured to show Acrobat reader (or another PDF reader) in the IFrame, or just download the PDF ?

I guess the embedded PDF reader prevents the browser from sending the "loaded" event, that is why the spinner stays forever and the div stays hidden...

nicoulaj commented 13 years ago

Updated by luanviet...@gmail.com on 2009-10-13T12:53:38

That's exactly what happen. The onload event never trigger in the iframe when source is a PDF. Yes, we need to show the pdf content.

nicoulaj commented 13 years ago

Updated by Julien.N...@gmail.com on 2009-10-14T16:02:10

I don't see a safe way to handle this...

Original ticket set status to Accepted (we converted to open)

nicoulaj commented 13 years ago

Updated by blake.be...@gmail.com on 2009-10-20T19:25:14

I have the same problem. Maybe have the IFrame object look at the extension of the url and if it is a pdf format then skip the progress bar and trigger the onload event manually.

nicoulaj commented 13 years ago

Updated by Julien.N...@gmail.com on 2009-10-22T08:17:42

PDF seems to be a very particular case: http://stackoverflow.com/questions/30005/how-do-i-fire-an-event-when-a-iframe-has-finished-loading-in-jquery

According to this article, onload events are not fired anymore for attachements on Firefox: http://www.atalasoft.com/cs/blogs/jake/archive/2009/08/18/events-to-expect-when-dynamically-loading-iframes-in-javascript-take-2-thanks-firefox-3-5.aspx So blake is right, we should skip the progress bar when we detect the content-type as "attachement".

The extension is not really reliable: look at luanvietnguyen's example PDF url... We have to directly look at the content-type declared by the browser for the iframe document.

nicoulaj commented 13 years ago

Updated by Julien.N...@gmail.com on 2009-10-30T14:20:22

Removed label Priority-Medium Added label Priority-Low

nicoulaj commented 13 years ago

Updated by blake.be...@gmail.com on 2010-09-13T21:09:24

This is a pretty easy fix. In the Iframe.as file add the following line of code in the commitProperties method.

//if pdf then load iframe now
if (source.indexOf("?") == -1) if (source.substr((source.length - 3),3) == "pdf") handleFrameLoad();

I have posted the source code to the file for anyone that wants to see the change. I hope this helps.

nicoulaj commented 13 years ago

Updated by blake.be...@gmail.com on 2010-09-14T15:37:14

There is one change that needs to be made to this line of code so that anchors are supported in the pdf file. The code should look like this:

if (source.indexOf("?") == -1) if ((source.substr((source.length - 3),3) == "pdf") || (source.substr((source.lastIndexOf("#") - 3),3) == "pdf")) handleFrameLoad();

This is to support the following type of url format in pdf:

http://www.example.com/example.pdf#page=1&view=fitH, top