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
jhonnajhonna 

Apex code on click of a abutton to render html in the same page layout

Hi,

  I am very new to Apex and Virtualforce development.  Here is what I need to do.. I need directions to how to go about it.

 

I have a custom button on Account page called  List Assests from XXX webpage.  When i click on it,  I need to load a a  400 X300 iframe with external URL like www.xxx.com/assests?id={!account.id} some where in the page layout with a list of assetts . I cannot leave the page or load it in a new window.  This should re render, every time I click the button.

 

Do my question is how do I associate a custom object, custom field to a VF page and how do i make it rerender from a button on the Account Page and make sure it all remains in the same page layout.

 

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

here is complete solution for you... :)

 

Create custom button , Detail page button with content source as Javascript

 

Here is code for your script

 

 

var url="http://www.xxx.com/assests?id={!Account.Id}";
var a = [];var re = new RegExp('\\bpbHeader\\b');var els = document.getElementsByTagName("div");for(var i=0,j=els.length; i<j; i++)if(re.test(els[i].className))a.push(els[i]);var parent=a[0];
var e=document.getElementById("FrameLoader");
if(e==null)
{
var Errordiv = document.createElement('div');
Errordiv.setAttribute('id','FrameLoader');
Errordiv.setAttribute('title','Download complete');
Errordiv.innerHTML = '<p><span class="ui-icon-circle-check ui-icon" style="float:left; margin:0 7px 50px 0;"></span>Assets Details  </p>';
parent.appendChild(Errordiv); 
var con=document.getElementById("FrameLoader");
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", url);
ifrm.setAttribute("frameBorder",0);
ifrm.style.width = 700+"px";
ifrm.style.height = 250+"px";
con.appendChild(ifrm); 
}

 

 

Special request Dont Play With Script Code ,

*** Just update your destination url..... :)

 

 

Cheers,

Bala 

All Answers

anil 007anil 007

 

hii try this code

 

<apex:page standardController="account" extensions="mypage">
<apex:form >
   <apex:pageBlock>
       <apex:sectionHeader title="Rerender Example"/>      
           <apex:commandButton value="Move your mouse here to refresh the time!">
               <apex:actionSupport event="onclick" rerender="time" status="refreshstatus"/>
           </apex:commandButton>
           <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>  
           <apex:outputpanel id="time">
               <apex:outputtext value="{!start}"/>
           </apex:outputpanel>  
   </apex:pageBlock>
</apex:form>  
</apex:page>

jhonnajhonna

Thanks a lot

b-Forceb-Force

here is complete solution for you... :)

 

Create custom button , Detail page button with content source as Javascript

 

Here is code for your script

 

 

var url="http://www.xxx.com/assests?id={!Account.Id}";
var a = [];var re = new RegExp('\\bpbHeader\\b');var els = document.getElementsByTagName("div");for(var i=0,j=els.length; i<j; i++)if(re.test(els[i].className))a.push(els[i]);var parent=a[0];
var e=document.getElementById("FrameLoader");
if(e==null)
{
var Errordiv = document.createElement('div');
Errordiv.setAttribute('id','FrameLoader');
Errordiv.setAttribute('title','Download complete');
Errordiv.innerHTML = '<p><span class="ui-icon-circle-check ui-icon" style="float:left; margin:0 7px 50px 0;"></span>Assets Details  </p>';
parent.appendChild(Errordiv); 
var con=document.getElementById("FrameLoader");
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", url);
ifrm.setAttribute("frameBorder",0);
ifrm.style.width = 700+"px";
ifrm.style.height = 250+"px";
con.appendChild(ifrm); 
}

 

 

Special request Dont Play With Script Code ,

*** Just update your destination url..... :)

 

 

Cheers,

Bala 

This was selected as the best answer