把我的应用类库再次整理了一下,发布上来大家交流!
http://www.cnblogs.com/Files/S.Sams/SamsJavaScriptLibrary.rar

  1/*------------------------------------------------------------
  2 *                    S.Sams Lifexperience
  3 * CopyRight (C) 2003-2007 S.Sams Lifexperience ScriptClassLib
  4 * MSNLive: S.Sams#msn.com
  5 * Http://blog.8see.net/
  6 * UPdate by : 2007-01-19 转载传播请保留版权
  7 *-----------------------------------------------------------*/

  8 
  9
 10/*    $ 获取指定对象
 11    @element    对象名
 12    可以使用对象名集合,返回值为对象的集合
 13    如果您使用了 Prototype 类库, 请把该函数注释掉
 14    Sams_object.Get() 中同样实现该函数的所有功能
 15*/

 16function $(element) {
 17  if (arguments.length > 1{
 18    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
 19      elements.push($(arguments[i]));
 20    return elements;
 21  }

 22  if (typeof element == 'string')
 23    element = document.getElementById(element);
 24  return element;
 25}

 26
 27/// 浏览器相关操作
 28var Sams_browse = {
 29    /*    检测浏览信息 */
 30    checkBrowser : function ()
 31    
 32                this.ver=navigator.appVersion 
 33                this.dom=document.getElementById?1:0 
 34                this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0
 35                this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0
 36                this.ie4=(document.all && !this.dom)?1:0
 37                this.ns5=(this.dom && parseInt(this.ver) >= 5?1:0
 38                this.ns4=(document.layers && !this.dom)?1:0
 39                this.mac=(this.ver.indexOf('Mac') > -1?1:0
 40                this.ope=(navigator.userAgent.indexOf('Opera')>-1); 
 41                this.ie=(this.ie6 || this.ie5 || this.ie4) 
 42                this.ns=(this.ns4 || this.ns5) 
 43                this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope) 
 44                this.nbw=(!this.bw) 
 45                return this;
 46    }
,
 47
 48    /*    设为首页
 49        @url        要设为首页的地址
 50    */

 51    SetDefault : function ()
 52    {
 53        this.style.behavior='url(#default#homepage)';
 54        this.setHomePage(this.GetUrl());
 55        return false;
 56    }
,
 57
 58    /*    复制指定URL地址
 59        @Msg        要写入剪贴板的字符集
 60    */

 61    SetCopy    : function (Msg){
 62        if(navigator.userAgent.toLowerCase().indexOf('ie') > -1{
 63            clipboardData.setData('Text',Msg);
 64            alert ("网址“"+Msg+"”\n已经复制到您的剪贴板中\n您可以使用Ctrl+V快捷键粘贴到需要的地方");
 65        }

 66        else 
 67        {
 68            prompt("请复制网站地址:",Msg); 
 69        }

 70    }
,
 71
 72    /*    加入收藏
 73        @site        站点名称
 74        @url        地址
 75    */

 76    AddBookmark : function (site, url){
 77        if(navigator.userAgent.toLowerCase().indexOf('ie') > -1{
 78            window.external.addFavorite(url,site)
 79        }
 else if (navigator.userAgent.toLowerCase().indexOf('opera') > -1{
 80            alert ("请使用Ctrl+T将本页加入收藏夹");
 81        }
 else {
 82            alert ("请使用Ctrl+D将本页加入收藏夹");
 83        }

 84    }
,
 85
 86    /*    打开Url指定宽度和高度的窗口 */
 87    OpenWindows : function (url,width,height)
 88    {
 89        window.open(url,'newwin','width='+width+',height='+height);
 90        return false;
 91    }
,
 92
 93    /*    禁止浏览器的Javascript错误提示 */
 94    CloseError : function(){
 95        window.onerror = function(){return true;};
 96    }
,
 97
 98    /*    获取浏览器URL */
 99    GetUrl : function(){
100        return location.href;
101    }
,
102
103    /*    获取URL参数 */
104    GetUrlParam : function(){
105        return location.search;
106    }
,
107    
108    /*    获取页面来源 */
109    GetFrom : function(){
110        return document.referrer;
111    }
,
112
113    /*    获取指定的URL参数值
114        @name        参数名
115    */

116    Request : function(name){
117        var GetUrl = this.GetUrl();
118        var Plist = new Array();
119        if(GetUrl.indexOf('?') > 0)
120        {
121            Plist = GetUrl.split('?')[1].split('&');
122        }

123        else if(GetUrl.indexOf('#') > 0)
124        {
125            Plist = GetUrl.split('#')[1].split('&');
126        }

127        if (GetUrl.length > 0)
128        {
129            for(var i=0; i<Plist.length; i++)
130            {
131                var GetValue = Plist[i].split('=');
132                if (GetValue[0].toUpperCase() == name.toUpperCase())
133                {
134                    return GetValue[1];
135                    break;
136                }

137            }

138            return;
139        }

140    }
,
141
142    /*    直接将HTML写到新窗口
143        @title        标题
144        @msg        内容
145    */

146    Popmsg : function PopIt(title,msg)
147    {
148        var popup = window.open('','popDialog','height=500,width=400,scrollbars=yes');
149        popup.document.write('<html><title>'+title+'</title><style>body{margin:10px;font:13px Arial;}span{text-line:20px;}</style><body><span style=\'font:14px arial;\'>'+msg + '</span></body></html>');
150        popup.document.close();
151    }

152}
;
153
154
155/// 对象操作
156var Sams_object = {
157    
158    /*    创建一个DIV对象
159        @ID            要创建的对象ID
160        @ClassName    创建对象的Class
161        @SetValue    设置该对象值
162        @ToDiv        将对象追加到指定的对象,如指定的对象不存在,则追加在Body的后面
163        返回        创建后的对象
164    */

165    CreateDiv : function (ID,ClassName,SetValue,ToDiv){
166        var creatediv = document.createElement('div');
167        if(ID != null) creatediv.id = ID;
168        creatediv.style.position = 'absolute';
169        if(ClassName != null) creatediv.className = ClassName;
170        if(this.Get(ToDiv))
171        {
172            this.Get(ToDiv).appendChild(creatediv);
173        }

174        else
175        {
176            document.getElementsByTagName('body')[0].appendChild(creatediv);
177        }

178        this.SetValue(ID,SetValue);
179        return this.Get(ID);
180    }
,
181    
182    /*    删除指定DIV对象
183        @objid        要删除的对象ID
184        返回        Bool 操作结果
185    */

186    DeleteDiv : function (objid)
187    {
188        try
189        {
190            if(this.Get(objid))
191            {
192                var GetParent = this.Get(objid).parentNode;
193                GetParent.removeChild(this.Get(objid));
194                return true;
195            }

196            else
197            {
198                return false;
199            }

200        }

201        catch(e)
202        {
203            return false;
204        }

205