I got a bit stuck on this little problem. I have a page that get's it's parameters from a layout button(url & formula). I need to use the parameters inside javascript ( angular). My problem is that some account's may have either single or double quotes which gives me "unexpected token errors".
So my question is : how can assign the passed parameters inside the javascript.

 var someObj ={accountLabel:"{!$CurrentPage.parameters.accountLabel}"}


  • Could you clarify, how you navigate to the Vf page. If that's from a custom button then with javascript onclick you could pass your data in the url and then you just need to parse the url using javascript ( angular in your case ). I had one scenario where in my accout details page for a related list with a custom button. I used to pass account id through url via javascript onclick on that button, then navigate to Vf page and then parse that url to get account id in javascript.
    – user477
    Jun 25 '15 at 21:59
  • there is a custom button on tha page layout that redirects to a url /apex/myPage?accountLabel={!object__c.Account_Name__c}
    – user682217
    Jun 28 '15 at 16:05

Take a look at this doc for other functions.


JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (), before unsafe JavaScript characters, such as the apostrophe ('). {!JSENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.

Try (Not tested)

 var someObj ={accountLabel:"{!JSENCODE($CurrentPage.parameters.accountLabel)}"}
  • tested and it works I thought the characters would be displayed escaped but they look normal. Thanks for help
    – user682217
    Jun 28 '15 at 16:06

You can also use this


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.