0

I have a inline VF page and trying to reload the parent window.

I am getting

Uncaught SecurityError: Blocked a frame with origin "https://ratan.ap1.visual.force.com" from accessing a frame with origin "https://ap1.salesforce.com". Protocols, domains, and ports must match.

Error.

Yaah i can understand this is not accessible because of inline VF page and the parent window domain is not same so it behave like this.

It is not make sense to me since the my inline VF page and standard page both are in same org and I am able to access the both page then I should able to access the parent window.

For reloading the page I found the workaround. I can use window.top.location = /object.Id;.

But wanted to know why this is necessary to have. If i am able to view the parent window then this should be accessible in my javascript.

1

2 Answers 2

0

This is happening because of same origin policy.

Why is the same origin policy so important?

Assume you are login to Salesforce org and visit a malicious website in another browser tab. Without same orgin policy the javascript of other tab could do anything with your Salesforce org. For example it can read your data inside the org.

As Salesforce wants to use javascript to enhance the user experience. So it is important that the browser can detect that this JavaScript is trusted to access Salesforce resources. That's where the same origin policy comes into play.

4
  • Yes I am agree with you but in case of VF page our inline VF page and standard page are in same org. so this should be accessible?
    – Ratan Paul
    Nov 13, 2015 at 6:51
  • Your inline vf page nothing but a iframe. URL is different for both of page, browser detect different URL so it enforce here same origin policy.
    – MIX DML
    Nov 13, 2015 at 6:54
  • It would be nice to have same domain for VF page and standard page.
    – Ratan Paul
    Nov 13, 2015 at 7:19
  • @RatanPaul You can not keep VF page and your sales force org same URL because you use VF page externally also in sites.
    – MIX DML
    Nov 13, 2015 at 8:06
0

Solution for this issue.

Use window.top.location = /object.Id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.