1

I have a custom button where I want to check for conformation. I wrote my javascript for conformation but I am getting error that

A problem with the OnClick JavaScript for this button or link was encountered: Unexpected token ILLEGAL

What is the reason behind this error. Please help me to solve this error.

my code :

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var txt;
var r = confirm("Are you sure!");
if (r == true) {
    url 
} 
3
  • What do url variable mean?
    – Gres
    Commented Apr 13, 2015 at 8:11
  • it is a url to my Vf page.
    – Anu
    Commented Apr 13, 2015 at 8:12
  • Hi Anu, did my solution work? if so, you can mark it as accepted. Commented Apr 13, 2015 at 18:14

2 Answers 2

1

Try to use following code:

var confirmation = confirm("Are you sure!");
if (confirmation == true) {
    window.location.href = url;
}
1

You need to put url in quotes. If you are evaluating your url using the {!} syntax, you need to quote that, eg var url = "{!salesforcefieldvalueOrCalc}"; Try this:

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}

var url = "{!salesforcefieldvalueOrCalc}";
var r = confirm("Are you sure!");
if (r == true) {
    //your URL should look like this line:
    //window.location.href = "https://na17.salesforce.com";
    //just make sure that url is evaluated as a string and you'll be able to
    //write it as:
    window.location.href = url;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .