惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
I
InfoQ
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Blog of Author Tim Ferriss
B
Blog
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
雷峰网
雷峰网
Recent Announcements
Recent Announcements
量子位
B
Blog RSS Feed

博客园 - 散步的蠕虫

[整理收藏]CSS Hack IE6,IE7,IE8 and Firefox 【转载】Javascript标准DOM Range操作 [收藏]winform拖动方法 [收藏]SQL SERVER2005自动备份 [更新+源码]一个随时随地随便记的超轻量级的记事本软件WheneverNote V1.0.9.218 [发布+源码]一个随时随地随便记的超轻量级的记事本软件WheneverNote V1.0.9.215 [总结]Server Application Error(IIS5 HTTP500)内部错误分析及解决办法 [转载]XML和HTML常用转义字符 C# TO Excel 新概念III WCF - Message Security with Mutual Certificates WCF - Common Security Scenarios 【转载】LINQ to SQL (Part 5 - Binding UI using the ASP:LinqDataSource Control) 【转载】LINQ to SQL (Part 4 - Updating our Database) 【转载】LINQ to SQL (Part 3 - Querying our Database) 【转载】LINQ to SQL (Part 2 - Defining our Data Model Classes) 【转载】Using LINQ to SQL (Part 1) 常用开发辅助工具清单 Local Resource应用概述
JavaScript 实用方法库
散步的蠕虫 · 2008-01-28 · via 博客园 - 散步的蠕虫

/*
/* JavaScript Document
*/


/* Calculate the length of character string */
String.prototype.len
=function()
{
    
return this.replace(/[^x00-xff]/g, "**").length;
}


/* Take out the blank both on left and right */
String.prototype.trim
=function()
{
    
return this.replace(/(^[\s+| +])|([\s+| +]$)/g,"");
}


/* Take out the left blank */
String.prototype.ltrim 
= function()
{
    
return this.replace(/(^[\s+| +])/g, "");
}


/* Take out the right blank */
String.prototype.rtrim 
= function()
{
    
return this.replace(/([\s+| +]$)/g, "");
}


/* Take out left and right blank and replace multi-blank by one blank */
String.prototype.atrim 
= function() 

    
return this.replace(/(^[\s+| +])|([\s+| +]$)/g,"").replace(/\s+| +/g," ");
}

    
/* Getting the version of browser 1-IE, 2-Firefox */ 
function getOs()
{
    
if(navigator.userAgent.indexOf("MSIE")>0)return 1;
    
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
    
return 0;
}

function RedirectLanguage(language)
        
{
            
var urlValue=window.location.href;
            
var returnURL=urlValue;
            
var indexOfQuestionMark=urlValue.indexOf("?");
            
if(indexOfQuestionMark>0)
            
{
                
var arrayUrl=urlValue.split('?');
                
var arrayParameter=arrayUrl[1].split('&');
                
var indexOfLang=arrayParameter[0].indexOf("Lang");
                
if(indexOfLang==0)
                
{
                    returnURL
=urlValue.replace(arrayParameter[0],"Lang="+language);
                }

                
else
                
{
                    returnURL
=arrayUrl[0]+"?Lang="+language+"&"+arrayUrl[1];
                }

            }

            
else
            
{
                returnURL
=urlValue.replace(/(\/+$)/g, "")+"?Lang="+language;
            }

            window.location.href
=returnURL; 
        }


posted on 2008-01-28 14:56  散步的蠕虫  阅读(231)  评论(0)    收藏  举报