2009-10-23 23 views
1

有關如何在發佈的文本中保留回車符的任何幫助?在帖子上丟失換行符/回車符

 
function checkPlayState(checkStatus) { 
    var Player = document.getElementById("NSPlay"); 
    if (Player.playState == 0 || Player.playState == 1) { // 0 vs 8 
     if (checkStatus == true) { 


      var tex_t = document.getElementById("ctl00_ContentPlaceHolder1_TextArea1").innerHTML; 


     // The following javascript function takes the URL of the target page and 
     // a name/value paire and POSTs the data to the supplied URL by dynamically 
     // creating a form and then submitting it... 
     // but I am loosing line-feeds/carage-returns in the transfer of the text 

     var fil_e = "Speach.aspx" // target url 

post_to(fil_e, tex_t); 

    function post_to (file, text) { 
     var myForm = document.createElement("form"); 
     myForm.action = file; 
     myForm.method = "post"; 


    var myInput = document.createElement("input"); 
    myInput.setAttribute("name", "key"); 
    myInput.setAttribute("value", tex_t); // squares show in the "Text Visualizer" when yellow is here 
    myForm.appendChild(myInput); // squares have gone in the "Text Visualizer" when we are here but show in the value field of watch window??? 

    document.body.appendChild(myForm); 
    myForm.submit();  
    document.body.removeChild(myForm); 
} 

      return; 

     } else { 

      window.setTimeout("checkPlayState(true)", 500); 
     } 

    } else { 

     window.setTimeout("checkPlayState(false)", 500); 

    } 
} 

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' I have this in aspx file to retrieve '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 


      Dim tex_t As Object 
      tex_t = Request.Form("key") 
      If tex_t "" Then ' Here while debugging the squares are gone?!? 

       TextArea1.InnerText = tex_t ' it is the same textarea too 

      Else 

      End If 

回答

1

使用URL編碼。新行表示爲%0A

http://www.javascripter.net/faq/escape.htm說,你可以使用JavaScript函數escape

function checkPlayState(checkStatus) { 
    var Player = document.getElementById("NSPlay"); 
    if (Player.playState == 0 || Player.playState == 1) { // 0 vs 8 
     if (checkStatus == true) { 


      var tex_t = escape(document.getElementById("ctl00_ContentPlaceHolder1_TextArea1").innerHTML); 

     // The following javascript function takes the URL of the target page and 
     // a name/value paire and POSTs the data to the supplied URL by dynamically 
     // creating a form and then submitting it... 
     // but I am loosing line-feeds/carage-returns in the transfer of the text 

     var fil_e = "Speach.aspx" // target url 

post_to(fil_e, tex_t); 

    function post_to (file, text) { 
     var myForm = document.createElement("form"); 
     myForm.action = file; 
     myForm.method = "post"; 


    var myInput = document.createElement("input"); 
    myInput.setAttribute("name", "key"); 
    myInput.setAttribute("value", tex_t); // squares show in the "Text Visualizer" when yellow is here 
    myForm.appendChild(myInput); // squares have gone in the "Text Visualizer" when we are here but show in the value field of watch window??? 

    document.body.appendChild(myForm); 
    myForm.submit();  
    document.body.removeChild(myForm); 
} 

      return; 

     } else { 

      window.setTimeout("checkPlayState(true)", 500); 
     } 

    } else { 

     window.setTimeout("checkPlayState(false)", 500); 

    } 
} 

然後你aspx文件使用:

Dim tex_t As Object 
tex_t = Request.Form("key") 
If tex_t "" Then ' Here while debugging the squares are gone?!? 

    TextArea1.InnerText = Server.UrlDecode(tex_t) ' it is the same textarea too 

Else 

End If 
0
 

for (i = 0; i -1) { 
        // 
       tex_t = tex_t.replace("something", %0A); 
       } 
      } 

0

UrlDecode的伎倆克里斯。 ..對不起,我無法在任何地方看到「添加評論鏈接」。

+0

剛剛發現了這個血腥的東西 - 正如我說的那樣 - 現在我所要做的就是找到複選框...將繼續保留它。再次感謝克里斯;) – Carpenter 2009-10-23 15:11:17