This is kind of annoying when developing javascript inside Visualforce: I can not find my global variables !

Build a Visualforce page with showHeader="false"

<apex:page showHeader="false">

Create a javascript global variable inside the page:

<script> var myVar = 'Hello'; </script>

Save your test page and open it via its URL.


Now in the browser console (F12 sometimes), type


and return gives you


Now insert this visualforce page as a section in a standard page layout.

Load the standard page and type in the console:


Which returns


What ?

Where art thou ?

2 Answers 2


On the standard page layout, visualforce pages are embedded in <iframe/> and the browser console show variable in scope of main page not their iframe (child frame). You can change the scope by selecting the frame.

As shown in image below:

enter image description here


The VF page is loaded inside a frameset and so will not be where you are expecting. Perhaps something like window.frames[x].myVar will give you what you need?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .