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

Referencing elements in Visualforce

Hi everybody.


I have been messing around with trying something and am not sure where I am doing this wrong, and was hoping someone might be able to point me in the right direction.


My very short visualforce code is included below. What I am trying to do is to create a visualforce page that contains an iframe that points to a salesforce dashboard. The page then also contains a small javascript segment that I want to eventually use to periodically refresh the dashboard presumably by firing off the click event on the dashboard's refresh button. I haven't created the periodical timeout loop, as I can't even reference the button.


My problem is that I am not able to reference the refresh button. I have tried many variations but I never seem to be able to find that button. Please if someone has an idea I would really appreciate a hint :)


Maybe I am using the wrong technology to reference the object, maybe I got the id wrong, at any rate, any help will be greatly appreciated :)



<apex:page sidebar="false" showHeader="false">
<div id="test">myText</div>
  <iframe id="box" src="" width="100%" height="1000" />
 <script language="javascript">




I think you are hitting the browser's cross site scripting security.  This effectively stops javascript accessing pages/windows/frames from other domains.  As your visualforce page is served from a different domain to, you can't access the details.


Hmm... that is a good point bob_buzzard. Any ideas how I can do this without running into that?


I've been playing around with javascript in a sidebar component that clicks various things.  The problem is that the sidebar doesn't get displayed for dashboards :(


Hmm... makes me wonder. Now we can add visualforce components directly to dashboards. Would you think cross-site scripting restrictions would still apply if I made a visualforce page specifically to click the button and added that as a component to a dashboard?


I think it would, as it would still come from the visualforce server rather than, as the rest of the dashboard.   


In my opinion, there is a syntax problem in the javascript code :




It seems that you have used 'document' twice in your code.


Try using the below mentioned code :




Hope this helps.