1

I'm trying to open popup window but I can't.

pagereference ps=new pagereference('/apex/Popupnewpage');
return ps;
3
  • 4
    You cannot open a popup from apex. This needs to be done in the VF page using JS. All you can do is redirect the entire page
    – Eric
    Apr 6, 2017 at 20:43
  • Thanks @Eric, Is there any possible to open new window via page reference?
    – Sriram
    Apr 6, 2017 at 20:47
  • 1
    No. As Eric said, PageReference is handled at the server level and you can only open popups at the client (JS) level. Apr 6, 2017 at 20:49

1 Answer 1

1

You cannot open popup window from controller.

You can either use commandbutton and use oncomplete method to open a popup

<apex:commandButton action="{!callMethod}" oncomplete="window.open('<url>','_blank','height=400,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1', 1)">

or commandLink to open a popup window

<apex:commandLink
value="Save" 
id="cmd1"  
target="_blank"  
action="{!callMethod}" 
onclick=" "  />
2
  • Thanks Guys for helping. Is there any possible open new window and auto closed with page reference?
    – Sriram
    Apr 6, 2017 at 21:11
  • Again, that can only be possible from visualforce or javacript Apr 6, 2017 at 21:12

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.