1

I have a visualforce page, in which I have a button that open a new visualforce page.

The problem I have is that the new page is too small (like a popup), and I want to set the width of my new page. It is possible ? And how can I do that ?

Thanks :)

Code

<apex:commandButton value="Enregistrer" action="{!enregistrer}" 
   onclick="enregistrerBlocks()" oncomplete="CloseAndRefresh()" rerender="msg"/>
  • Can you please post some code snippet, what you have tried so far? – Saroj Bera Jan 4 '16 at 9:49
3

Assuming you are using window.open, set the width and height

window.open("http://www.w3schools.com", "_blank", "width=400, height=400");

http://www.w3schools.com/jsref/met_win_open.asp


<!DOCTYPE html>
<html>
<body>
<a href="#" onclick="window.open('http://www.w3schools.com/', 'newwindow', 'width=300, height=250'); return false;">
   Click here to open new window
</a>
</body>
</html>

Use this code implement here http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open

<apex:commandButton value="Click Me" action = "{!method2}" 
 oncomplete="window.open('http://www.w3schools.com', '_blank', 'width=400, height=400');"/>
| improve this answer | |
  • Thank you @Ratan, but my page is open via an appex:commandButton and not a link.... – dou Jan 4 '16 at 9:52
  • @dou Can you please add your commandButton code. If you are using commandButton then you are using oncomplete for open new window ? correct me if I am wrong. – Ratan Paul Jan 4 '16 at 9:54
  • <apex:commandButton value="Enregistrer" action="{!enregistrer}" onclick="enregistrerBlocks()" oncomplete="CloseAndRefresh()" rerender="msg"/> the oncomplete parameter is already used by calling an othe javascript function, that close my page and refresh the other page – dou Jan 4 '16 at 10:04
  • @dou one more request where you are using window.open for opening new VF page. is in this method CloseAndRefresh if yes pls add this function code as well. Just provide me the code where you are opening new VF page – Ratan Paul Jan 4 '16 at 10:06
  • 1
    I just tried with your method, and changing my oncomplete parameter and I can change th esize of the window ! Thank you :) But As I said in my answer I found an other way to change th e size of the window, but by changing some parameters in salesforce. It's cool that there is two differnets ways to do that, I'll try to remember your answer ''cause it coulb be very usefull, thank you ;) – dou Jan 4 '16 at 10:09
0

Well I think I post my question too fast because I just find how to do that ^^ In salesforce, in the parameters of my button (custom button or link) I choose the button that open my new page and click the Window Open Properties button and here we can change the size (height and width, and some other things) of the displayed page !

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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