Include page with Ajax - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Giovanni MolteniGiovanni Molteni 

Include page with Ajax

Hi Guys,
i'm wondering in how to show Lead page in the home (i need to show dashboard too)
Is it possible using ajax or php, to include that page?
Or there's an easier way to customize the width of a visualforce page in the dashboard?

thx
Matt BrownMatt Brown
Dashboard is easy as it is a standard Homepage Component you can add to the Homepage Layout. If you want to show the Lead list view/homepage on the Home tab I would recommend a combination of Visulforce and an HTML Homepage Component. Here you go:

Visualforce page:

Create a Visualforce page and call it something like "LeadsView"

< apex : page standardController="Lead" showHeader="false" >
    < apex : ListViews type="Lead" / >
< / apex : page >

HTML Homepage Component:

< iframe src="/ apex / LeadsView" ="" framborder="0" height="900" width="100%" > < / iframe >

(as this post doesn't like code I had to place spaces everywhere so you need to remember that when pasting)

You might need to play with the height etc.

Also, be sure to add your new Homepage Component to the Homepage Layout.
Giovanni MolteniGiovanni Molteni
great idea, but if i click on a lead link into the html component in my home page, it appears inside the iframe, creating a little confusioned view (window in another window). is there a chance to get all links intro the iframe opened in the top frame?
thx again
Matt BrownMatt Brown
Ok change the iFrame tags for Embed tags, so it would look like this:

< embed src="/ apex / LeadsView" ="" framborder="0" height="900" width="100%" > < / embed >
Giovanni MolteniGiovanni Molteni
thank you again for your reply. the embed object shows the datas correctly but any link to any lead is still opening in the frame. is there a way to force to open links reloading the page?
thx
Matt BrownMatt Brown
Ok it sounds like the code is not placed correctly. Edit the Homepage Component (HTML right?) and delete any code you may have there. Then select the "Show HTML" checkbox in the top right of the editor and then copy the embed code above. Now save.

I have tested mine and it opens up the Lead in the Lead tab from the link on the Homepage.
Giovanni MolteniGiovanni Molteni
tried to clean everything but still no result... ;-(
resuming:
1) develop - pages - new page label "leads" -

<apex:page standardController="Lead" showHeader="false" >
    <apex:listViews type="Lead"/>
</apex:page>

2)customize - home - home page components - new
<embed src="/apex/leads" frameborder="0" height="900" width="100%">

3)home page layout assigned to the user - select wide component to show and select the component

is ti possbile that i setted up some parameter while "playing" with the preferences?
thx again and sorry to bug...
Giovanni MolteniGiovanni Molteni
i'm analizing the html code and, as shown in this image http://prntscr.com/13kqd , the parameter of target associated to the form is _self...
Giovanni MolteniGiovanni Molteni
SOLVED: added, in the apex page, thi js script<br /> &lt;script&gt;<br /> onload = function() {<br /> &nbsp;&nbsp;&nbsp; var frame = parent.frames[0].document;<br /> &nbsp;&nbsp;&nbsp; var links = frame.getElementsByTagName('a');<br /> &nbsp;&nbsp;&nbsp; for (var i=0; i&lt;links.length; ++i) {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; links[i].setAttribute('target','_parent');<br /> &nbsp;&nbsp;&nbsp; }<br /> }<br /> &lt;/script&gt;<br />
Matt BrownMatt Brown
So weird that you had to add that, but glad you got it working.:)
Jeroen van KempenJeroen van Kempen
Hi,
I have been trying to solve this issue... Somehow it does not seem to be working, also if I add the <script> to the Visualforce page. I am trying to show a customView of a custom object with the enhancedList.... Here is the code... If I remove the Script it does what it is supposed to do, but then the links link inside the <embed> tag... 

<apex:page standardController="Project_info__c" >
<script>
onload = function() {
    var frame = parent.frames[0].document;
    var links = frame.getElementsByTagName('a');
    for (var i=0; i<links.length; ++i) {
        links[i].setAttribute('target','_parent');
    }
}
</script>
<apex:enhancedList type="Project_info__c" listId="00B50000006OE5a" height="300" customizable="false"  rowsPerPage="25"/>

</apex:page>