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
mattpick1mattpick1 

Iframe containing a VF page communication with the parent window.

Hi,

 

I have a VF page as a homepage component specifically so it loads some script each time the user changes page (this used to be done by an S-control but we are moving it over). 

 

My problem is I am no longer able to reference a variable within the iframe from a custom button (using the execute javascript on-click). With the S-control it was simply:

 

iframe.var

 

Unfortunately this isn't working for the VF page and iframe - I think it maybe because the script is embedded within the body of the apex page as opposed to in the head - is there a way of making the script in a visualforce page appear in the head?

 

 

Thanks

 

Matt

Best Answer chosen by Admin (Salesforce Developers) 
mattpick1mattpick1

**SOLUTION**

 

The <apex:includescript> component moves any scripts (referenced as static resources by setting the value attribute) into the header of the generated HTML.

All Answers

mattpick1mattpick1

**SOLUTION**

 

The <apex:includescript> component moves any scripts (referenced as static resources by setting the value attribute) into the header of the generated HTML.

This was selected as the best answer
NaishadhNaishadh
I am also facing the same issue. Can you please provide some sample code.
mattpick1mattpick1

Hi Naishadh,

 

If you include your javascript as a static resource then you can use the <apex:includescript> component to include it in the header of the visualforce page.

 

eg.

 

<apex:includescript value="{!$Resource.myScript}"/>