Find your content:

Search form

You are here

Can you get Apex in a Home page component without using an iframe?


The question is fairly straightforward - is there a way to get apex into a home page component (left side/narrow component) without resorting to loading a visualforce page in to an iframe?

I can't use an iframe but I need to be able to access things like static resources, user IDs, and other elements that are fairly easy to do in apex. I have some workarounds in place but they feel a little hack-ish. If there is a proper way to do that I'd love to try that approach.

Attribution to: Ryan Elkins

Possible Suggestion/Solution #1

Outside of doing something like using the AJAX toolkit or the REST API this isn't possible as far as I know. Visualforce is served from a separate subdomain so the javascript same-origin policy prevents you from doing an AJAX load of content from it into an HTML component as well.

You may want to look into the AJAX toolkit's proxy if you're willing to proxy your visualforce content through custom javascript but that ends up being a lot of work to write.

Attribution to: ca_peterson

Possible Suggestion/Solution #2

your only choice at this point is Javscript. I am doing the same thing as we speak.

  1. google cdn reference to jquery,
  2. $.ajax(function(){ load visualforce page, returns json}
  3. render json data into page.

and you need to use jsonP as well. visualforce pages are housed on a different domain.

function jsonpcallback(data){

        url: '{!host}/apex/<VFPAGE>',
        dataType: "jsonp",
        jsonp : "callback",
        jsonpCallback: "jsonpcallback",
        success: function() { console.log("success"); }, 
        error: function(a,b,c,d) { console.log("error"); } 


the vf page:

<apex:page controller="CONTROLLER" contentType="application/json">

Attribution to: ebt
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content