<?php
$txt_value = $_GET['td_2_input'];
$txt_value_area = str_replace("<br>","/r/n",$txt_value);//for be_input_txt_area
$txt_value = str_replace(" "," ",$txt_value);//for td show blank line start
$txt2_value = $_GET['td_to_txt'];
//$txt2_value = str_replace(" "," ",$txt2_value);
$txt2_value = str_replace("<BR>","/r/n",$txt2_value);//ie <BR>
$txt2_value = str_replace("<br>","/r/n",$txt2_value);//ff <br>
?>
<html>
<head>
<script>
function inputtable(){
txt_area = document.getElementById("txtarea").value;
/*check ie or firefox*/
var Version = navigator.appVersion;
//alert(Version);
check_Version = Version.substr(17,4);
if (check_Version == "MSIE")
{
/*change blank in ie*/
//alert("ie");
var reg = new RegExp("/r/n","g");
txt_area = txt_area.replace(reg,"<br>");
}else{
/*change blank in firefox*/
//alert("firefox");
var reg = new RegExp("/n","g");
txt_area = txt_area.replace(reg,"<br>");
}
alert(txt_area);
window.location = "table_textarea_br.php?td_2_input="+txt_area;
}
function tdtotxtarea(){
td_value = document.getElementById("td_2").innerHTML;
var reg = new RegExp(" ","g");
td_value = td_value.replace(reg," ");
window.location = "table_textarea_br.php?td_to_txt="+td_value;
}
//从php中转换过的 txt_value_area 在js中也需判断/r/n和/n
function check_ff_br(){
txt2_value = document.getElementById("txtarea_2").value;
var Version = navigator.appVersion;
//alert(Version);
check_Version = Version.substr(17,4);
if (check_Version == "MSIE")
{
/*change blank in ie*/
//alert("ie");
var reg = new RegExp("/r/n","g");
txt2_value = txt2_value.replace(reg,"xxxx");
}else{
/*change blank in firefox*/
//alert("firefox");
var reg = new RegExp("/n","g");
txt2_value = txt2_value.replace(reg,"xxxx");
}
alert(txt2_value);
}
</script>
</head>
<body>
<textarea id = "txtarea" style= "height:10%;width:10%;"></textarea>
<input id = "be_input_txtarea" type = "button" value = "pushin" onclick="inputtable();"></input>
<textarea id ="txtarea_2" style= "height:10%;width:10%;"><?php echo $txt_value_area;?></textarea>
<input type = "button" value = "txt2" onclick ="check_ff_br();"></input>
<br/>
<br/>
<br/>
<table border = "1" style = "width:30%;table-layout:fixed;">
<tr>
<td style="width:30%">111</td>
<td id = "td_2" style="width:40%;word-wrap:break-word;"><?php echo $txt_value;?></td>
<td style="width:30%;">333</td>
</tr>
</table>
<input type ="button" value = "td_to_txt" onclick = "tdtotxtarea();"></input>
<textarea style= "height:10%;width:30%;"><?php echo $txt2_value;?></textarea>
</body>
</html>