Forum Moderators: open

Message Too Old, No Replies

Javascript Email Function Line Breaks

Inserting HTML line breaks into javascript

         

julep821

12:43 am on Jun 25, 2004 (gmt 0)

10+ Year Member



Hi guys, I have an email function that allows me to send an email from a webpage. It pops up the default mail client with the subject and text already in it.

My problem is that I'm trying to insert line breaks at key points of the email and I have been unsuccessful in doing so.

I have tried the \n and <br> to no avail.

The part where I'm specifically trying to do this is below.

document.add_user.encoding="html";
document.add_user.method="get";
document.add_user.action=firstline+secondline+thirdline+fourthline+fifthline+sixthline+seventhline+eigthline+ninthline+tenthline;

I have variables declared with the email message for each of the variables listed above. I have tried the line breaks both in the variables themselves and in the .action call, concatenating with the variables.

CAn you insert HTML code into Javascript?

Thanks in advance.

DrDoc

12:56 am on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld!

I would think that \n should work...
Have you tried \\n?

julep821

12:57 am on Jun 25, 2004 (gmt 0)

10+ Year Member



Hi DrDoc, thanks for the reply. Going to give that a go and see how that works.

Purple Martin

1:26 am on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are putting the string variables into a form's action attribute. Action attributes are URLs. So maybe you need to URL encode it. Ever noticed how spaces get changed to %20 in a URL? Well the code for a (Windows) carriage return is %0d in a URL, so try that. There is a full chart of all 256 charcters here:
[i-technica.com...]

julep821

1:42 am on Jun 25, 2004 (gmt 0)

10+ Year Member



I could kiss you! Thank you so much Purple, it worked. I didn't even think about the URL encoding. :)