Preserve carriage returns in a javascript variable

I want to be able to preserve carriage returns in a javascript variable. I have a javascript variable "notes" which if I do


the alert box shows that the carriage returns in the variable are in place. Good. The problem is that I need to send this variable onto another html page. I do this with this following code (I don't have php on the server so all of this being done with javascript)"checkalert/checkalert.html?notesinput="+notes,"_newtab");

On checkalert.html, I retreive notesinput into a javascript variable and do an alert. Now I have lost the carriage returns which were in the variable notes on the previous screen.

Could somebody please help me with some javascript code on how to keep the carriage returns for when the data lands on checkalert.html

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
You can use escape() :"checkalert/checkalert.html?notesinput="+escape(notes),"_newtab");

Open in new window

In the target page use unescape()  to get the original back.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RupertAAuthor Commented:
Perfect. Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.