function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion 

Redirect to a page on click of an image on VF page---Please help!!!

Hi All,

       I have an image on my visualforce page (which is rendered as pdf as well). I want that image to redirect me to a link say : google  when it;s clicked. This redirection should also work when the page is rendered as pdf. This is what i have tried so far and itt doesnt work. Request you all to help.


    <script type="text/javascript">
    function popupwindow(){
        var newwindow ="");


<apex:image url="{!$Resource.PDFImage}" onclick="popupwindow" width="550" height="50"/>


I  have also tried to use <a></a> tags , just outside <apex:image> but even that doesn't seem to work.



Shrey Tyagi


Hi Shrey,

In PDF script won't work.

do like below,

<apex:image url="{!$Resource.PDFImage}" onclick="'');" width="550" height="50"/>


This may help you.

I tried this already , doesn't work. Thanks for your time!!!


do like this then,


<apex:image url="{!$Resource.PDFImage}" onclick="'');" width="550" height="50"/>


<a href="" style="height:50px;width:50px;background-image:{!$Resource.PDFImage}" > </a>


Hi Shrey,


Can you please try this out?


<apex:outputLink value="" id="CommandLink1"> 
                        <apex:image url="{!$Resource.PDFImage}" width="550" height="50"/> 


  I tried this as well, it doesn't work.


I tried using the following code that worked perfectly for me. Just try it and let us to know the result


<apex:page renderAs="pdf" >
<apex:form >
<apex:outputLink value="">Click Here</apex:outputLink>


**Caution: Use https instead of http while referencing the link


Also as a best practice use images from static resources while rendering pdf 




Visit my blog here

Thanks a lot for your time Georg. This doesn't wok. I believe the reason it works for you is because you have a link. Links and email addresses are clickable in PDF file( i.e cursor becomes a pointed finger on roll over). But in case of images upon click of an image, its boundaries get highlighted and no redirection happens. Try redirecting upon click of an image rather  than giving it as a link and it wont work.


Thanks a lot for your help !!!!