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
JustinMccJustinMcc 

Button on VF Page used in standard layout reloads iFrame not whole page

Hello

 

so I have a visualforce page that displays a table of information that I use on a standard object's page layout.  There is a command button in this Visualforce page, my problem is that when I click the command button instead of the whole page being redirected it only redirects the iFramew when used as part of a Page layout.

 

Is there any way to get this button to redirect the whole page?

 

Thanks,

 

Justin

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I don't think there is using a commandbutton, as there's no suitable attributes for this and it has to be controlled client side.

 

If you can swap your comandbutton for a  commandlink, you can specify the target="_top" attribute which should do the trick.  You can also style your commandlink to look like a button (try style="btn")

 

Message Edited by bob_buzzard on 03-22-2010 04:58 AM

All Answers

bob_buzzardbob_buzzard

I don't think there is using a commandbutton, as there's no suitable attributes for this and it has to be controlled client side.

 

If you can swap your comandbutton for a  commandlink, you can specify the target="_top" attribute which should do the trick.  You can also style your commandlink to look like a button (try style="btn")

 

Message Edited by bob_buzzard on 03-22-2010 04:58 AM
This was selected as the best answer
TomSnyderTomSnyder
I like style trick above, but if it doesnt work (Ex. not using standardstysheet?) this should do the trick too...

 

 

 

 

<input class="btn" type="button" value="click me" onClick="javascript:window.top.location.replace("{!returnUrl}") />

 

 

 

bob_buzzardbob_buzzard
Does that work?  I would expect the browser to stop you loading a different page into the main window, as the VF section comes from a different domain.  It also won't post any information back to the controller - is that what you want?
TomSnyderTomSnyder

Yes, it works even cross-domain.   You can even POST cross-domain to top page such as:

 

<form action="https://c.cs3.visual.force.com/apex/myVFpage" method="POST" target="_top">

 

notice how i used the FQN of the VF page, if wont work if you POST to http://cs3.salesforce.com/apex/myVFpage since this will redirect and drop the POST data...GET will work though