I'm trying to open a link in a new window but I can't. Here is my code:

<apex:commandButton value="Open" onclick="window.open=('/apex/newRic?id={{item.id}}','_blank'); return false;"/>

The {{item.id}} is an angular variable.

If I try to modify the code like this, it works but opens the link in the same window:

<apex:commandButton value="Apri" onclick="window.location=('/apex/newRic?id={{item.id}}'); return false;"/>

Help me! Thanks in advance!

  • 1
    If you are using angular you could just skip using the VF tag and just use a normal button or ngclick...
    – PepeFloyd
    May 12, 2015 at 15:06

1 Answer 1


You have the wrong parameter passed in the following statement:


It should be '_blank' instead of 'blank'.

Note: Due to your browser settings, the window may just open in a new tab instead of a new window. The workaround for it is passing one more parameter specifying height and width of the window:

  • Thanks for the answer! In my code there was "_blank", when I wrote the code here I was wrong... Anyway the code you give dosn't work for me, it doesn't anything: it doesn't update the page or open new tab or new window. It refresh the page but donsn't open anything.
    – DarkSkull
    May 12, 2015 at 14:55
  • no Js errors in the console log ? May 12, 2015 at 15:09
  • @SamuelDeRycke SyntaxError: missing : in conditional expression but it refers to a css code.
    – DarkSkull
    May 12, 2015 at 15:27
  • Hey @DarkSkull, the issue is you have an = sign in between window.open and opening parenthesis! Try after removing it.
    – ajinkyah
    May 12, 2015 at 15:49
  • The correct statement would be: window.open('/apex/newRic?id={{item.id}}','_blank','height=200,width=200');
    – ajinkyah
    May 12, 2015 at 15:52

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.