在最近一个小屁项目中,没有服务端(其实服务端是人家早已经写好的服务),留给我的就只有一大堆的Html和JS,写的好烦躁,所以就写了几个扩展。
多个不说的,这里只是记录,code附上,便以后查询:
代码
测试代码:
代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>
<html xmlns="http://www.w3.org/1999/xhtml%22>
<head>
<title></title>
<style type="text/css">
body
{
background-color: Black;
}
div
{
border-bottom-width: 1px;
border-left-width: 0px;
border-top-width: 1px;
border-right-width: 0px;
border-style: solid;
border-color: Lime;
width: 98%;
margin: 8,8;
padding: 10px;
background-color: Black;
color: Olive;
}
</style>
<script src="Wolf.Utils.JSExtesion.js" type="text/javascript"></script>
<script type="text/javascript">
function StringTest() {
document.getElementById("result1").innerHTML = String.format("My blog : cnBlogs:{0} ,CSDN :{1}", "http://www.cnblogs.com/whitewolf/%22, "http://blog.csdn.net/grzx2210%22)
+ "<br/>" + " Wolf ".trim() + " Wolf ".trimLeft() + " Wolf ".trimRight() + "122".isInteger();
}
function StringBuilderTest() {
var sb = new StringBuilder();
sb.appendFormat("My blog : cnBlogs:{0} ,CSDN :{1}", "http://www.cnblogs.com/whitewolf/%22, "http://blog.csdn.net/grzx2210%22);
sb.append("<br/>");
sb.append(" remove");
sb.remove(2);
sb.append("whitewolf");
sb.appendLine("<br/>");
document.getElementById("result2").innerHTML = "tostring()" + sb.toString() + "<br/>tostring(';')" + sb.toString(";");
}
function UriTest() {
var uri = new Uri();
document.getElementById("result3").innerHTML = "searchString:" + uri.searchString + "<br/>id=" + uri.QueryParam("id", "id empty");
}
function Test() {
StringTest();
StringBuilderTest();
UriTest();
};
</script>
</head>
<body onload="Test();">
<div id="result1">
</div>
<div id="result2">
</div>
<div id="result3">
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>
<html xmlns="http://www.w3.org/1999/xhtml%22>
<head>
<title></title>
<style type="text/css">
body
{
background-color: Black;
}
div
{
border-bottom-width: 1px;
border-left-width: 0px;
border-top-width: 1px;
border-right-width: 0px;
border-style: solid;
border-color: Lime;
width: 98%;
margin: 8,8;
padding: 10px;
background-color: Black;
color: Olive;
}
</style>
<script src="Wolf.Utils.JSExtesion.js" type="text/javascript"></script>
<script type="text/javascript">
function StringTest() {
document.getElementById("result1").innerHTML = String.format("My blog : cnBlogs:{0} ,CSDN :{1}", "http://www.cnblogs.com/whitewolf/%22, "http://blog.csdn.net/grzx2210%22)
+ "<br/>" + " Wolf ".trim() + " Wolf ".trimLeft() + " Wolf ".trimRight() + "122".isInteger();
}
function StringBuilderTest() {
var sb = new StringBuilder();
sb.appendFormat("My blog : cnBlogs:{0} ,CSDN :{1}", "http://www.cnblogs.com/whitewolf/%22, "http://blog.csdn.net/grzx2210%22);
sb.append("<br/>");
sb.append(" remove");
sb.remove(2);
sb.append("whitewolf");
sb.appendLine("<br/>");
document.getElementById("result2").innerHTML = "tostring()" + sb.toString() + "<br/>tostring(';')" + sb.toString(";");
}
function UriTest() {
var uri = new Uri();
document.getElementById("result3").innerHTML = "searchString:" + uri.searchString + "<br/>id=" + uri.QueryParam("id", "id empty");
}
function Test() {
StringTest();
StringBuilderTest();
UriTest();
};
</script>
</head>
<body onload="Test();">
<div id="result1">
</div>
<div id="result2">
</div>
<div id="result3">
</div>
</body>
</html>
效果:
本文转自破狼博客园博客,原文链接:http://www.cnblogs.com/whitewolf/archive/2010/11/19/1881490.html,如需转载请自行联系原作者