Problem with Error: Expected ')'... | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| |
Hi all.
I have problem with this string javascript : - onclick="if(confirm('Confirm?')) location.href('form.asp?A=terry.d'arby'); return false;
The error javascript is:
Error: Expected ')'
Why? Can you help me?
Kind regards
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by viki1967 Can you help me? sure, your url string is invalid, you have alltogether 5 unescaped ' in your line (is that 2 and a half strings?), thus the last ) is part of a string.
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by Dormilich sure, your url string is invalid, you have alltogether 5 unescaped ' in your line (is that 2 and a half strings?), thus the last ) is part of a string. When resolve my problem?
thanks
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by viki1967 When resolve my problem? as soon as you can.
you have four options (I know of) - use the typographical apostrophe (U+2019)
- use encodeURI()
- nest the string (use " and ')
- escape the non-delimiter '
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'...
thanks, but I try this and not working... -
onclick="if(confirm('Confirm?')) location.href('Form.asp?A=' + encodeURIComponent(terry.d'arby) + '); return false;
-
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
well, you have 5 unescaped and 1 escaped ' (similar situation like before)
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by Dormilich well, you have 5 unescaped and 1 escaped ' (similar situation like before) I don't understand.. sorry...
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
hm, not sure how the return string of encodeURIComponent is treated. Quote:
Originally Posted by MDC encodeURIComponent escapes all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( ) what about - onclick="if(confirm('Confirm?')) location.href('Form.asp?A=' + encodeURIComponent(terry.d'arby) + '); return false;
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by Dormilich hm, not sure how the return string of encodeURIComponent is treated. Not working: - onclick="if(confirm('Confirm?')) location.href('Form.asp?A=' + encodeURI(terry.d'arby) + '); return false;
Not working: - onclick="if(confirm('Confirm?')) location.href('Form.asp?A=encodeURI(terry.d'arby)); return false;
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
think of what you wrote there. - onclick="if(confirm('Confirm?')) location.href('Form.asp?A=' + encodeURI(terry.d'arby) + '); return false;
- onclick="if(confirm('Confirm?')) location.href('Form.asp?A=encodeURI(terry.d'arby)); return false;
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
something that just popped to my attention: - location.href = new_URI;
-
// not
-
location.href(new_URI);
at least that’s what’s defined in the specs
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'...
Nothing... - onclick="if(confirm('Sure?')) location.href = 'Form.asp?A='+encodeURI(terry.d'arby)+''; return false;
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
any error messages?
—
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'... Quote:
Originally Posted by Dormilich any error messages?
Error: Expected ')' :(
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'...
use one of the other two possibilities mentioned earlier.
| | Familiar Sight | | Join Date: Oct 2007
Posts: 254
| | | re: Problem with Error: Expected ')'...
I don't not use... any example please?
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,662
| | | re: Problem with Error: Expected ')'... |  | Similar JavaScript / Ajax / DHTML bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|