javascript
  • node.js
  • 2016-03-24 58 views 0 likes 
    0

    當我運行下面的代碼:包括reponse.write鏈接

    res.write("Author: "); 
    res.write("<a href='" + tweet[i].Link + "' target='_blank'>" + tweet[i].Lable + "</a> \n"); 
    res.write("Date: " + tweet[i].TDate + "\n"); 
    

    我得到這個:

    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 
    

    正如你所看到的,鏈接不工作

    但當我刪除第一行res.write("Author: ");時:

    esti_palombo Date: 2016-03-12T00:00:00.000Z AbdElrazek_Esam Date: 2016-03-08T00:00:00.000Z 
    

    鏈接工作正常,但新行\n不起作用!

    有人可以幫我這個

    回答

    0

    <br/>

    2

    替換「\ n」通過拒絕寫一個適當的標題,請嘗試,你迫使瀏覽器來猜測它。正如你所看到的,僅僅改變你的數據格式就是讓它猜測不同。

    設置內容類型text/html,你會在您的文章的第二種情況,因爲你正在寫你不使用換行符打破行HTML,您使用的段落或換行(<br>)。

    相關問題