String.prototype实现的一些javascript函数
//String.prototype使用
//批量替换,比如:str.ReplaceAll([/a/g,/b/g,/c/g],["aaa","bbb","ccc"])
String.prototype.ReplaceAll=function (A,B) {
var C=this;
for(var i=0;i<A.length;i++) {
C=C.replace(A[i],B[i]);
};
return C;
};
// 去掉字符两端的空白字符
String.prototype.Trim=function () {
return this.replace(/(^[\t\n\r]*)|([\t\n\r]*$)/g,'');
};
// 去掉字符左边的空白字符
String.prototype.LTrim=function () {
return this.replace(/^[\t\n\r]/g,'');
};
// 去掉字符右边的空白字符
String.prototype.RTrim=function () {
return this.replace(/[\t\n\r]*$/g,'');
};
// 返回字符的长度,一个中文算2个
String.prototype.ChineseLength=function()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
};
// 判断字符串是否以指定的字符串结束
String.prototype.EndsWith=function (A,B) {
var C=this.length;
var D=A.length;
if(D>C)return false;
if(B) {
var E=new RegExp(A+'$','i');
return
相关文档:
<script language="javascript" type="text/javascript">
// <!CDATA[
function Test()
{
document.location.href = 'test. ......
with(document)
{
write ("test");
write
("dsasfda");
}
上面是用了with
如果不用的话就要这样写了
document.write (" ......
.net中前台javascript与后台c#相互调用
C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C# ......
//创建一个新的用户对象,接受一个有许多属性的对象作为参数
function User(properties)
{
for(var i in properties){(function(which){
var p=i;
//创建此属性的一个新的读取器(getter)
which["get"+p] = function(){
&nbs ......
静态方法的实质与任何其他一般函数没有什么不同,最主要的区别在于,其他函数是以对象的静态属性形式存在的。作为一个属性,它们不能在该对象的实例的上下文中访问,而只属于主对象本身的那个上下文中。对习惯了传统类式集成的人来说,这就像类里定义的静态方法。
  ......