Reputation: 2140
When I run the following code:
res.write("Author: ");
res.write("<a href='" + tweet[i].Link + "' target='_blank'>" + tweet[i].Lable + "</a> \n");
res.write("Date: " + tweet[i].TDate + "\n");
I got this:
Author: <a href='https://twitter.com/esti_palombo' target='_blank'>esti_palombo</a>
Date: 2016-03-12T00:00:00.000Z
Author: <a href='https://twitter.com/AbdElrazek_Esam' target='_blank'>AbdElrazek_Esam</a>
Date: 2016-03-08T00:00:00.000Z
As you can see, the links do not work
But when I remove the first line res.write("Author: ");
:
esti_palombo Date: 2016-03-12T00:00:00.000Z AbdElrazek_Esam Date: 2016-03-08T00:00:00.000Z
links are working fine but the new line \n
does not work !!
Can someone help me with this
Upvotes: 0
Views: 22
Reputation: 67380
By refusing to write a proper header, you're forcing the browser to guess it for you. As you can see, simply changing the format of your data is making it guess differently.
Set the content type to text/html
and you'll be in the second case of your post, and since you're writing HTML you don't use newlines to break lines, you use paragraphs or line breaks (<br>
).
Upvotes: 2