javascript framework, JS常用函数(方法),jQuery
2010-01-22 17:16
741 查看
//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
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
相关文章推荐
- jquery刷新页面 页面跳转 js常用函数
- jQuery中常用的函数方法总结
- jQuery 常见操作实现方式和常用函数方法总结
- jquery 刷新页面方法和一些javascript基础函数
- 常用jQuery(Js)方法
- js常用数组函数方法
- js和jQuery常用方法区分
- JS and jquery 常用函数
- 让js中的函数只有一次有效调用的三种常用方法
- Jquery 及 javascript写函数的方法
- jQuery 常见操作实现方式和常用函数方法总结
- javascript(js)iframe里的页面调用父窗口js函数的方法或弹出窗口调用父窗口js函数的方法
- 在网页中JS函数自动执行常用三种方法
- 【JavaScript】JS实现继承最常用的方法
- jquery动态加载js/css文件方法(自写小函数)
- js与jquery常用数组方法总结
- 玩转web之javaScript(五)---js和jquery一些不可不知的方法(input篇)
- jQuery和JS:网页常用计算宽高的方法
- jquery和javascript的区别(常用方法比较)
- jquery和javascript的区别(常用方法比较)