maxum
maxum

Reputation: 2915

Newline ignored in mailto:

I am have items added to a 'cart' which is just a div. When I add them I add a <br /> to the end to make things look tidy. When it's done the user can hit a link and the contents of the div is set in the link. When the email opens all the items are joined together with no newline, so figured I need to replace the <br /> with a \n but this is being ignored also.

   function br2nl(str) {
        return str.replace(/<br\s*\/?>/mg,"\n");
    }      

  function addtocart(part)
 {
 $('#cart').append(part + '<br />'); 
 var body = br2nl($('#cart').html());
 $('#maillink').attr("href","mailto:?subject=Parts&body=" + body)
 }

Upvotes: 0

Views: 218

Answers (1)

Bart
Bart

Reputation: 17361

The mailto function will fail with HTML. Use plain text.

Newline characters can be included using it's url encoded equivalent %0D.

Upvotes: 2

Related Questions