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
vikash singh 9vikash singh 9 

Access elements of parent iframe on standard page.

i have added a section on my Opportunity standard page. In that section I added a vf page. Now when i see the console i found that whole code of my vf page is inside an iframe . I want to access the outer elements of this iframe from inner elements of my vf page. Basically i need to access elements of standard page through my vf page.
It gives me this error : Uncaught SecurityError: Blocked a frame with origin "https://c.na15.visual.force.com" from accessing a frame with origin "https://na15.salesforce.com". Protocols, domains, and ports must match.

Please Help me .
Best Answer chosen by vikash singh 9
Ashish_SFDCAshish_SFDC
Hi Vikash, 


Domain of parent page and the its origined iframe page must be same to access parent frame javascript from child frame javascript or jquery. This is a basic security feature which prevents javascript injection from cross-domain sites.

Even if your domain is same and one is using https:// and its child frame using http:// javascript will not work because protocol is different. No browser support cross-domain referencing. Its a browser security feature.

Only solution is redirecting the page through controller using Pagereference when you have done something on page or use same domain.

Edit (found a useful link):

Explained in more detail - http://javascript.info/tutorial/same-origin-security-policy

http://salesforce.stackexchange.com/questions/17639/iframe-protocols-domains-and-ports-must-match-error


Regards,
Ashish