You need to sign in to do that
Don't have an account?
![Brian Chipman 4 Brian Chipman 4](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Visualforce page new window size and position
Have a Detail Page Button on an object that open a Visualforce page in a new window. How do I set the size and position of that new window?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
This is will help you. If it helps mark this as best answer so that others can benefit too.
https://salesforce.stackexchange.com/questions/19005/custom-button-to-visualforce-page-in-new-window-popup-size
Regards,
Santosh.
Here is the working and tested code snippet to open window in the center.Can replace page name and Width/Height.
Also CHange button behavior to : Execute Javascript.
Note: It will not work for extended window on dual Monitor.
Javascript buttons will work properly only in Classic and not in Lightning Experience
Below solution works for both Classic and lightning and this how we have transformed our javascript buttons during Migration.You can keep this until Classic version is decomissioned completely and then meanwhile you can transform to lightning components and use quick actions.
Works both in Lightning & Classic :
1. Create a vf page with below snippet.
2. Create a detail Page button and add below vf page.
3. Keep the old classic button as is.
4. Add newly created button on pagelayout to the lightning layout buttons section and remove classic button from same lightning buttons layout.
5. This way user can switch between functionalities and button still can work in both classic and Lightning.
vf page snippnet :
ButtonVfpage :
Hope this Helps!
--Santosh.
For the details page button, I set...
Content Source = Visualforce Page
Behavior= Display in new window.
I put an alert on about line 22; "alert(sforce.one);" and when run, it says 'Undefined' so I would expect just the classic window to open. standardController has been set to 'Case' just like the Vf page I want to display.
I replaced "apex/TTT" with "apex/myvisualforcepage". "myvisualforcepage" has standardController="Case" and references an extension. I get a "List has no rows for assignment to SObject" error whereas this page works without error when called directly from the button.
Is your Vf page example above where I am to put my code and controller references or am I calling my already created vf page with "apex/TTT"? --You need to put your vf page and reference related controller into that page.
I replaced "apex/TTT" with "apex/myvisualforcepage". "myvisualforcepage" has standardController="Case" and references an extension.-- This steps is correct replace the vf page (TTT) with yours.
Do the following steps.
1. on Detail page button.
Behavior = 'Execute Javascript.'
Content Source = 'onClick Javascript.'
2. Step1 makes button functionality work in Classic.
3. Create a Quick Action. Select Action Type : Custom visualforce & Select related vf page from dropdown (you will se vf page as you have std controller defined on page.)
4. Select Height as 500px or whatever you feel it's right, give name same as the one in classic & Save
5. Add the above quick action to 'Salesforce Mobile and Lightning Experience Actions' on related page layout.
6. Due to steps 1 thru 5, user can see the same button both in Classic and Lightning.
When i tried above steps i was able to make it work in both versions.
Hope this helps!