views:

170

answers:

2

I'm loading pdf's into an iframe on my web page by setting the src of the iframe to the path of the pdf document. This works as I'd like for viewing the pdf.

The problem is that some of the pdf's have hyperlinks in them to external websites which, when clicked, load the external website in my iframe.

So my question is: is it possible to catch the pdf's hyperlink click in javascript in the parent browser window, set the target to either top or blank and then redirect the request?

Unfortunately the pdf's are supplied by a third party so I don't have access to change the documents themselves.

+2  A: 

Some ideas:

  • You can try hooking into the iframe's load/readystatechange event to catch when the iframe is loading another url.
  • You can "poll" the iframe every n interval and compare the src attribute to the URL of the pdf.

After you catch the change, you can redirect and open a window with the proper url. But browsers may block the JS pop-up window.

Jeff
+1 I thought about using the `onPropertyChanged` but there's no such event for IFrame (or Frame for that matter).
Paulo Santos
A: 

Hi James, Its not the Answer, I am also stucked with exaclty same problem, Did you found the solution... Could you please help me.. thanks

Ashok Gupta