Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 3 pages, a homepage and then two other pages. Depending on what the user clicks on in the homepage I want to redirect them to one of the two other VF pages. How would I do this using JS or JQuery?


share|improve this question
up vote 6 down vote accepted

Simple answer:

    window.location = '{!urlfor($Page.yourpagenamehere)}';

Complicated answer: You need to consider why you're doing this instead of just using an apex:outputLink with the value set to the same as the above. If you're doing it because you have some special handler on the item then that makes some sense, but otherwise I'd do the following to redirect pages:

<apex:outputLink value="{!urlfor($Page.yourpagenamehere)}">Link Title</apex:outputLink>

Or use a commandLink with an action that calls into a controller or extension method that returns a PageReference (PageReference auto redirects on return from action type tags).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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