javascript framework, JS常用函数(方法),jQuery

//Register NameSpace for window.MSN
if(!window.MSN)
{
    window.MSN = {};
}

if(!window.MSN.SET)
{
    window.MSN.SET = {};
}

if(!window.MSN.SET.Utilities)
{
    window.MSN.Utilities = {};
}


//Check you borwse type
//IE7 &IE8 & FF etc can render hover for div tags, but can't render under IE6.0
//this function can render hover for div under IE6.0 browse
//
MSN.SET.Utilities = {

    WebBrowserType: { IE6: 'MSIE 6.0', IE7: 'MSIE 7.0', IE8: 'MSIE 8.0', Firefox: 'Mozilla', Unknow: 'unknow' },

    checkUserWebBrowser:function(){
         var userAgent = window.navigator.userAgent;
        
         if(userAgent.indexOf(MSN.SET.Utilities.WebBrowserType.IE8) > -1) {
             return MSN.SET.Utilities.WebBrowserType.IE8;
         }
        
         if(userAgent.indexOf(MSN.SET.Utilities.WebBrowserType.IE7) > -1) {
             return MSN.SET.Utilities.WebBrowserType.IE7;
         }
        
         if(userAgent.indexOf(MSN.SET.Utilities.WebBrowserType.IE6) > -1){
             return MSN.SET.Utilities.WebBrowserType.IE6;
         }
        
         if (userAgent.indexOf(MSN.SET.Utilities.WebBrowserType.Firefox) > -1) {
            return MSN.SET.Utilities.WebBrowserType.Firefox;
         }
        
         return MSN.SET.Utilities.WebBrowserType.Unknow;
    }
}
//Start function
//Check you borwse type
//under IE6.0 can't render hover
//this function can render hover for div under IE6.0 browse
//
function $1() {
    // check users IE browse
    if(window.MSN.SET.Utilities.checkUserWebBrowser() == "MSIE6.0")
    {
        hover();
    };
}
$1();


//define function getElementByClass
//this function only for div tags, and if you want to apply another tags
//please change code /*var allPageTags = document.getElementsByTagName("div");*/
//return an object just like /*document.getElementById*/
document.getElementByClass = function(classname) {
    var elements = [];
    //populate the array with all the page div tags
    var allPageTags = document.getElementsByTagName("div");
    //cycle through the tags using a for loop
    for (i = 0; i < allPageTags.length; i++) {
        //pick out the tags with our class name
        fullclassname = allPageTags[i].className;
        if (fullclassname.indexOf(classname) > -1) {
            elements[elements.length] = allPageTags[i];
        }
    }
    return elements;
}

//change classname for special tags
//find this classname /*nav_section*/ and add /* onhover*/
//example <div class="nav_section section1 onhover">
function hover() {
    var onhoveclassname = " onhover";
    obj = document.getElementByClass("nav_section");
    var currentclassname;
    for (var i = 0; i < obj.length; i++) {
        obj[i].onmouseover = function() {
            currentclassname = this.className;
            this.className = currentclassname + onhoveclassname;
        };
        obj[i].onmouseout = function() {
            this.className = currentclassname
        };
    }
}

 

jQuery download: http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.js 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值