Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
常用JS函数
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chen Liqiang  
View profile  
 More options Feb 24 2007, 2:24 am
From: "Chen Liqiang" <chen...@gmail.com>
Date: Sat, 24 Feb 2007 07:24:26 -0000
Local: Sat, Feb 24 2007 2:24 am
Subject: 常用JS函数

/**
 * 去除空格
 */
String.prototype.trim = function()
{
        return this.replace(/(^[\s| ]*)|([\s| ]*$)/g, "");

}

/**
 * 去除左空格
 */
String.prototype.ltrim = function()
{
        return this.replace(/(^[\s| ]*)/g, "");
}

/**
 * 去除右空格
 */
String.prototype.ltrim = function()
{
        return this.replace(/([\s| ]*$)/g, "");

}

/**
 * vbscript 的left函数,取字符串最左边len个字符
 */
function left(str,len) {
        return str.substr(0,len);
}

/**
 * vbscript 的right函数,取字符串最右边len个字符
 */
function right(str,len) {
        if (str.length-len>=0 && str.length>=0 && str.length-len<=str.length)
{
                return str.substring(str.length-len,str.length)
        } else {
                return null
        };
}

/**
 * 简化getElementById
 */
function $(s)
{
        return document.getElementById(s);

}

/**
 * 创建新html元件
 */
function $c(s)
{
        return document.createElement(s);

}

/**
 * 判断html元件是否存在
 */
function exist(s)
{
        return $(s)!=null;

}

/**
 * 输出html内容
 */
function dw(s)
{
        document.write(s);

}

/**
 * 判断一个变量是否为空
 */
function isNull(_sVal)
{
        return (_sVal == "" || _sVal == null || _sVal == "undefined");

}

/**
 * 删除节点
 */
function removeNode(s)
{
        if(exist(s))
        {
                $(s).innerHTML = '';
                $(s).removeNode?$(s).removeNode():$(s).parentNode.removeChild($(s));
        }

}

/**
 * 刷新页面
 */
function refreshPage() {
        window.location.reload();

}

/**
 * 字符串长度
 */
function strlen(key){
        var l=escape(key),len;
        len=l.length-(l.length-l.replace(/\%u/g,"u").length)*4;
        l=l.replace(/\%u/g,"uu");
        len=len-(l.length-l.replace(/\%/g,"").length)*2;
        return len;
}

/**
 * 取URL参数
 */
function GetUrlParam( paramName )
{
        var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
        var oMatch;
        try {
                oMatch = oRegex.exec( window.top.location.search ) ;
        } catch (e) {
            oMatch = oRegex.exec( location.search ) ;
        }

        if ( oMatch && oMatch.length > 1 )
                return unescape( oMatch[1] ) ;
        else
                return '' ;


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google