When click on activity name in my visualforce page, another visualforce page will open with parameters. Iam passing two parameters to visualforce page through URLFOR() function.

Code Snippet:

<apex:repeat value="{!activityList}" var="activity">
<div onClick="openDetail('{!activity.Id}','{!contactId}');">{!activity.name}                   </div> 

<script type="text/javaScript"> function
openPropertyDetail(actid,contid) {
var link =    '{!URLFOR($Page.ActivityPage,null,activityId=actid,contactId=contid])}';
window.open(link); }

Now the problem iam facing is, when i click on activity name the ActivityPage will open but not getting parameters inthe URL.

Can you please any one help on this.



2 Answers 2


The URLFOR is a Visualforce tag that is rendered ONCE the page is loaded/re-rendered (the value of the tag is resolved on the server). It allows only plain text values or apex variables. So you CAN'T pass javascript variables in it. What you can do it to reference your visualforce page using URLFOR and add parameters separately to the string:

var pageUrl = '{!URLFOR($Page.ActivityPage)}';
var parameters = '?activityId=' + actid + '&contactId=' + contid;
var link = pageUrl + parameters;

Your link variable should look like this.

var link = '{!URLFOR($Page.ActivityPage,null)}'+'?activityId='+actid+'&contactId='+contid;

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.