1

I'm trying to implement this in Confluence pages.

Basically, I have a PDF file (exported from Powerpoint), which has hyperlinks embedded, so when you click on the links in the PDF it opens whatever page the link is.

This PDF file is opened within an iframe in the Confluence page (which is created using a custom user macro).

Unfortunately, on Firefox and IE, the PDF links open the new page within the iframe, rather than the parent window. Chrome's inbuilt PDF viewer works fine (opening in the parent window).

Also unfortunate is that I don't know much about javascript or HTML. The code we are using currently for the 'create iframe' custom macro in Confluence is as follows:

## @param Url:title=URL|type=string|required=true|desc=URL for the iFrame 
<script type="text/javascript"> 
jQuery(function($) { 
    var ratio = Math.sqrt(2); 
    var target = $("#f"); 

    function fixRatio() { 
          target.width("100%"); 
          if (target.width() > 1000) { 
                  target.width(1000); 
          } 
        target.height(Math.ceil(target.width() / ratio)); 
    } 

    $(window).bind("resize", fixRatio); 

    fixRatio(); 
}); 
</script> 

<iframe id="f" src="$paramUrl" width="100%" style="border:0">x</iframe> 

Now, most of this is just to do with sizing the iframe approximately to the PDF file (for aesthetic reasons).

Basically what I want to know is how do I get any links from the PDF opening not in the iframe but in the parent window?

I thought about performing an operation on the iframe window unload, something like

window.onunload=function()

within the javascript, or

<body onunload="somecode">

in the HTML, but I'm not sure where to place it or what the code is that I would need to force the new page to be passed to the parent window and rendered there instead of the iframe.

I've tried

<base target="_parent" />

but because the PDF viewer is separate from the rest of the page in the iframe it doesn't seem to work.

Sorry I'm very new to this, we did get a someone to help us but he wrote the code then didn't stick around to help with any issues, and I've only seen my first HTML and javascript today! So trying to learn fast...

Thanks!

  • I'm afraid I don't know how to fix your problem, but I would advise in general against using iframes. You could, instead, simply attach the PDFs you want to a page in confluence and then link directly to those PDFs instead of having a page which shows them in an iframe. – MNRSullivan Apr 08 '13 at 17:31
  • Thanks for the reply, although unfortunately simply attaching the PDFs isn't an option given the path we are taking. Embedding PDFs in iframes was the best option we had, but we didn't realise this problem would come up... – user2249482 Apr 08 '13 at 18:10
  • I believe confluence is going to have the functionality to display PDFs and microsoft office documents in version 5, but until then there is no work around that I know of which is going to function like you need – MNRSullivan Apr 09 '13 at 13:58

0 Answers0