nholland
Newbie
Posts: 1
Registered: 1/4/2003
Member Is Offline
|
| posted on 1/4/2003 at 09:59 PM |
|
|
Maintaining an apostrophe!
I am currently developing a website that uses the tree menu within a FAQ application. Some question and answer have apostrophes in them. These
aprostrophes cause a Javascript error.
Any ideas on how I can display these without errors?
By the way, the Tree Menu is superb, thanks.
|
|
|
Ulukai
Member
Posts: 40
Registered: 11/27/2002
Location: Frankfurt, Germany
Member Is Offline
|
| posted on 1/6/2003 at 10:00 PM |
|
|
Possible Solutions
Hi.
One Solution is to reverse the order the quotes and apostrophes appear in the tree-script. This is a lot to do and does not fit if the user enters a
quote.
Another solution is to parse the strings for critical characters like the quote and replace them by the corresponding javascript / html
escape-sequences.
This would be \" for a quote in javascript and " for html.
I wrote such a stringparser which should be easy to modify. It was written for private purposes, so I made no hard tests on it and it may be not
elegant and even slow but it works.
You are free to use it.
The arrays defined at the beginning of the file are pairs of search/replace String-Arrays. Modify them for fitting your needs.
Have fun
Ulukai
Attachment: stringparse.js (6.6kb)
This file has been downloaded 402 times
|
|
|