I have a Visualforce page that is embedded on the detail page of Opportunities.
Within the page is a command button that invokes a method in the backing controller extension.
Once the backing method is complete, how can I redirect the user to another page?
I can return a PageReference from the method but it will only redirect the iframe that the embedded Visualforce page is displayed in.
Ideally I'd like to refresh the top level window but I'm concerned there may be cross domain issues if the embedded visualforce page isn't in the same domain as the parent window.
As a basic test in I tried adding the following to the embedded Visualforce page:
<script>
window.setTimeout(testRedirect,2000);
function testRedirect() {
top.location.reload();
}
</script>
This resulted in Chrome logging the error:
Unsafe JavaScript attempt to access frame with URL https://na2.salesforce.com/006400000000000 from frame with URL https://ab2.na2.visual.force.com/servlet/servlet.Integration?lid=066400000000000&ic=1. Domains, protocols and ports must match.
So the domains differ for the Visualforce page.
window.top.location.href
on completion. – Creolized