7

I have created a VisualForce home page component that uses the Analytics API to show a chart.

<apex:page >
<analytics:reportChart reportId="XXX" size="tiny" cacheResults="false"></analytics:reportChart>
</apex:page>

When users click on the chart, the chart's report opens in the component's iframe. How should I get the report to open in the top window?

4

Try wrap it with link to your report like this:

<a onclick="window.top.location = '/REPORT_ID'">
        <analytics:reportChart reportId="REPORT_ID"  size="tiny" cacheResults="false"></analytics:reportChart>
    </a>
|improve this answer|||||
  • this isn't working – jaw999 Mar 7 '16 at 18:11
  • This also does not work for me. <analytics:reportChart> will always trump and ignore the surrounding anchor. – rmarq423 Jun 14 '17 at 15:46
1

You should be able to use the <base> html tag in the VF page markup to target the links within the iframe to open in the top-most window.

This works with other types of items rendered within Visualforce Home Page Components and should, in theory, work with the charts as well.

<apex:page >
    <!-- all links in this VF page will target the top-most window element -->
    <base target="_top" />

    <analytics:reportChart reportId="XXX" size="tiny" cacheResults="false"></analytics:reportChart>
</apex:page>

Similarly, an example that uses the enhancedList tag in a VF page embedded within a Home Page Component (iframe).

<apex:page showHeader="true" sidebar="false">
    <base target="_top" />
    <apex:enhancedList type="Activity" height="300" rowsPerPage="10"  />
</apex:page>
|improve this answer|||||
  • I wasn't able to get your first example to work correctly. There must be some relevant implementation difference between the reportChart tag and the enhancedList tag. (Thanks for replying to this, though.) – Randolph Oct 2 '14 at 12:31
  • @user10299, well that's too bad. I didn't look at the report chart component specifically to see what technology it is using but the <base> tag generally comes in handy for situations like this. – Mark Pond Oct 2 '14 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.