This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Issue with special characters in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Issue with special characters in javascript" Watch "Issue with special characters in javascript" New topic
Author

Issue with special characters in javascript

Sanjaykar Gurram
Greenhorn

Joined: May 05, 2008
Posts: 22
Hi

I am having issue passing text containing special characters to a javascript function. Would like to know if there is any special means to pass text like this.

Ex: onclick="loadPopup('My Saloon's Test')" <----- Text having special character( ' )

If i do this it shows script error "Expected )".

Please let me know how do i handle this.


Thanks,
Sanjay
Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

For future reference, there is a HTML and JavaScript forum that you should use instead of this one. Special characters need to be escaped. Traditionally the escape character is backslash. Try the following


OCJP6, OCWCD5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Issue with special characters in javascript
 
Similar Threads
How to handle Special Characters ?
How to check for a particular word in a string.
Problem accessing the form object of a different frame
iterating with a scriptlet, can't get the values into js arr
javascript special characters