87,926
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<textarea id="ttaInput" rows="10" cols="100">function helloWorld(sYourName)
{
alert("Hello, " + sYourName);
}
helloWorld("csdn");</textarea>
<input type="button" id="btnJoin" value="Join Lines" />
</body>
<script type="text/javascript">
<!--
function $(sId)
{
return document.getElementById(sId);
}
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
};
$("btnJoin").onclick = function() {
var oArea = $("ttaInput");
var strArray = oArea.value.split("\r\n");
if (strArray.length > 1)
{
for (var i in strArray)
{
strArray[i] = strArray[i].trim();
}
oArea.value = strArray.join("");
eval(oArea.value);
}
};
//-->
</script>
</html>