+ Start a Discussion

Not able to display dashboard in visualforce page

<apex:page sidebar="false" showHeader="false">
<apex:includeScript value="{!$Resource.jQuery}" />
jQuery( function ($) {

     $('#iframeID').load( function() {              
         var $frameDoc = this.contentWindow.document,
             urlMatch = /srcUp\(%27(.*)%27\)/;

         $('a[href*="srcUp"]', $frameDoc).each( function () {
             this.href = decodeURIComponent(this.href.match(urlMatch)[1]);


<apex:iframe id="iframeID" src="https://nirmallya2016-dev-ed.my.salesforce.com/01Z280000006Md4?isdtp=vw" height="500px" width="600px" frameborder="true"/>
<br />
Getting the following error message in Browser console. 

User-added image
Martijn SchwarzerMartijn Schwarzer
Hi Nirmallya_Ghosh,

Your error is related to CORS (Cross-origin Resource Sharing). Basically, this means that if you want to load content from another domain, you will have to whitelist this domain.

To do this, follow these steps:
  • From Setup, enter CORS in the Quick Find box, then select CORS.
  • Choose New.
  • Enter an origin URL pattern.
The origin URL pattern must include the HTTPS protocol and a domain name, and may include a port. The wildcard character (*) is supported and must be in front of a second-level domain name. For example, https://*.example.com adds all subdomains of example.com to the whitelist.
The origin URL pattern can be an IP address. However, an IP address and a domain that resolve to the same address are not the same origin, and you must add them to the CORS whitelist as separate entries.

For more information, check this page from Salesforce help:


Let me know if this helps!

Best regards,
Martijn Schwärzer