javascript 日历提醒系统( 兼容所有浏览器 )

功能介绍:
1.正常的日历功能。
2.等等等
3.接收 数组
例如:


代码如下:

new Calendar("id").show(
{
"20091120": "今天干了嘛嘛。。。",
"2009320": "今天干了嘛嘛。。。"
}
);

日历提示样式分为3类。
a. 当日
b.当年当月当日提示样式
c.当月当日提示样式
鼠标覆盖在有提示的日期上自动出现提示内容
4.。。。。。
主要分为2种用处。
1.提供一个 div 或其他 element 将该容器的 id 传给 Calendar。方法名为: show()
例: var cr = Calendar("div1");
cr.show( /*data - 该数组为可选项,如果传则有提示功能*/ );
2.提供一个 input[type='text'] 的元素 将该元素的 id 传给 Calendar。方法名为: pop()
例: var cr = Calendar("input2");
cr.pop();
其他的就不多说了。觉得好的话,就支持下。呵呵。
有什么问题或好的想法,请告诉我。谢谢
详细的用法和例子在压缩包里有。
演示地址
http://img.jb51.net/online/calendar/demo-1.html
http://img.jb51.net/online/calendar/demo-2.html
打包下载地址 http://www.jb51.net/codes/12595.html


代码如下:

/*
* Calendar
* Language 0: Chinese, 1: English
* 1.Put calendar into the element html use 'show()'
* 2.Pop-up calendar use 'pop()'
*/

var Calendar = function( instanceId, language, startYear, endYear ){
    if( typeof instanceId == "string" ){
        this.Date     = new Date();
        this.Year     = this.Date.getFullYear();
        this.Month     = this.Date.getMonth();
        this.Week    = this.Date.getDay();
        this.Today    = this.Date.getDate();

this.InstanceId = instanceId;
        this.Language    = language     || 1;
        this.StartYear    = startYear || this.Year - 5;
        this.EndYear    = endYear     || this.Year + 1;

// If instance is input[type='text'] object
        this.popContainer_id = 'popCalendarContainer';

// Message store
        this.msgStore = [];

this.caleContainer_id = 'calendarContainer';
        this.caleTop = {
            today_view_id:        'calendarTodayView',
            week_view_id:        'calendarWeekView',
            lq_year_id:            'linkQuickYear',
            lq_month_id:        'linkQuickMonth',
            sq_year_id:            'selectQuickYear',
            sq_month_id:        'selectQuickMonth',
            close_id:            'calendarClose',
            prev_month_id:        'toPrevMonth',
            back_today_id:        'backToday',
            next_month_id:        'toNextMonth'
        }
        this.daysContainer_id = 'calendarDaysContainer';
        this.msgContainer_id = 'calendarTipsContainer';

this.curDayClass =         'calendarCurrentDay';
        this.tipDayClass =        'calendarTipDay';
        this.oldTipDayClass =    'calendarOldTipDay';
    }
};
/* Calendar language */
Calendar.lang = {
weeks:     [
                ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
                ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
            ],
weeksMenu:[
                 ["日","一","二","三","四","五","六"],
             ["SUN","MON","TUR","WED","THU","FRI","SAT"]
    ]
};
/* Create calendar element */
Calendar.prototype._getViewElement = function(){
    // Create page html element
    var caleElem = "";
        // Create Start
        caleElem+= '<div id='+this.caleContainer_id+'>';

// <Top>
        caleElem+= '<div id="calendarTopContainer"><table cellpadding="0" cellspacing="0"><tr>';

// Top day view
        caleElem+= '<td id='+this.caleTop.today_view_id+'></td>';

// Link or select control
        caleElem+= '<td>';
        caleElem+= '<div id='+this.caleTop.week_view_id+'></div>';
        caleElem+= '<table id="calendarYearMonthContainer" cellpadding="0" cellspacing="0">';
        caleElem+= '<tr>';
        caleElem+= '<td>';
        caleElem+= '<a id='+this.caleTop.lq_year_id+' href="javascript:void(0);"></a>';
        caleElem+= '<select id='+this.caleTop.sq_year_id+'></select>';
        caleElem+= '</td>';
        caleElem+= '<td>.</td>';
        caleElem+= '<td>';
        caleElem+= '<a id='+this.caleTop.lq_month_id+' href="javascript:void(0);"></a>';
        caleElem+= '<select id='+this.caleTop.sq_month_id+'></select>';
        caleElem+= '</td>';
        caleElem+= '</tr>';
        caleElem+= '</table>';
        caleElem+= '</td>';

// Quick control
        caleElem+= '<td>';
        caleElem+= '<div id="calendarCloseContainer">';
        caleElem+= '<a id='+this.caleTop.close_id+' href="javascript:void(0);">x</a>';
        caleElem+= '</div>';

caleElem+= '<div id="calendarQuickContainer">';
        caleElem+= '<a id='+this.caleTop.prev_month_id+' href="javascript:void(0);">«</a>';
        caleElem+= '<a id='+this.caleTop.back_today_id+' href="javascript:void(0);"> </a>';
        caleElem+= '<a id='+this.caleTop.next_month_id+' href="javascript:void(0);">»</a>';
        caleElem+= '</div>';
        caleElem+= '</td>';

caleElem+= '</tr></table cellpadding="0" cellspacing="0"></div>';
        // </Top>

// <Calendar View>
        caleElem+= '<div id="calendarMainContainer">';
        // Week menu
        caleElem+= '<div id="calendarWeeksContainer">';
        for(var i = 0; i < 7; i ++){
        caleElem+= '<span>'+Calendar.lang["weeksMenu"][this.Language][i]+'</span>';
        }
        caleElem+= '</div>';

// Days view
        caleElem+= '<table id='+this.daysContainer_id+' cellpadding="0" cellspacing="0">';
        for(var tr = 0; tr < 6; tr ++){
        caleElem+= '<tr>';
        for(var td = 0; td < 7; td ++){
        caleElem+= '<td><span></span></td>';
        }
        caleElem+= '</tr>';
        }
        caleElem+= '</table>';

caleElem+= '</div>';
        // </Calendar View>

caleElem+= '</div>';

// <Calendar msg>
        caleElem+= '<div id='+this.msgContainer_id+'></div>';
        // </Calendar msg>

// Create End
    return caleElem;
};
/* Get Month Data */
Calendar.prototype._getMonthViewArray = function( year, month ){
    var monthArray = [];
    // From the beginning day of the week
    var beginDayOfWeek = new Date( year, month, 1).getDay();

// This month total days
    var daysOfMonth = new Date( year, month + 1, 0).getDate();

// 42: 7*6 matrix
    for( var i = 0; i < 42; i ++ )
     monthArray[i] = " ";

for( var j = 0; j < daysOfMonth; j ++ )
        monthArray[j + beginDayOfWeek] = j + 1 ;

return monthArray;
};
/* Search the index of option in the select */
Calendar.prototype._getOptionIndex = function( selectObject, value ){
    for( var j = 0; j < selectObject.options.length; j ++ ){
        if( value == selectObject.options[j].value )
            return j;
    }
};
/* Bind year data into 'Year select' */
Calendar.prototype._bindYearIntoSelect = function(){
    var oYear = this.find( this.caleTop.sq_year_id );
    var oYearLen = 0;
    for( var i = this.StartYear; i <= this.EndYear; i ++, oYearLen ++ )
        oYear.options[oYearLen] = new Option( i , i );
};
/* Bind Month data into 'Month select' */
Calendar.prototype._bindMonthIntoSelect = function(){
    var oMonth = this.find( this.caleTop.sq_month_id );
    var oMonthLen = 0;
    for( var i = 0; i < 12; i ++, oMonthLen ++ )
        oMonth.options[oMonthLen] = new Option( i + 1 , i + 1 );
};
/* Bind data */
Calendar.prototype._bindAllData = function( curYear, curMonth ){
    var cr = this;
    // Bind default Data into 'select:Year'
    this._bindYearIntoSelect();

// Bind default Data into 'select:Month'
    this._bindMonthIntoSelect();

// Change the 'select:Year' and 'select:Month' value
    this.changeSelectValue( curYear, curMonth );

// Bind default data into 'current day view and current week view'
    this.find( this.caleTop.week_view_id ).innerHTML = Calendar.lang['weeks'][this.Language][this.Week];
    this.find( this.caleTop.today_view_id ).innerHTML = this.Today;

// Get days and bind into 'CalendarMain'
    // Add current day class and mouse event
    var daysOfMonthArray = this._getMonthViewArray( curYear, curMonth );
    var spans = this.find( this.daysContainer_id, "span" );
    var curYMD = this.Year + "" + ( this.Month + 1 ) + "" + this.Today;
    var selectYear = this.find( this.caleTop.sq_year_id ).value;
    var selectMonth = this.find( this.caleTop.sq_month_id ).value;
    for( var i = 0; i < spans.length; i ++ ){
        spans[i].innerHTML = daysOfMonthArray[i];
        var selectYMD = selectYear + "" + selectMonth + "" + spans[i].innerHTML;
        if( curYMD == selectYMD )
            spans[i].className = this.curDayClass;
        else
            spans[i].className = "";
    }
    // If not some days has pop message
    if( this.msgStore != "" )
        this._initPopMsg( this.msgStore );
}
/* Bind event */
Calendar.prototype._bindAllEvent = function(){
    var cr = this;
    // 'toPrevMonth, toNextMonth, backToday, today view' event
    this.find( this.caleTop.prev_month_id ).onclick = function(){ cr.goPrevOrNextMonth(this); };
    this.find( this.caleTop.next_month_id ).onclick = function(){ cr.goPrevOrNextMonth(this); };
    this.find( this.caleTop.back_today_id ).onclick    = function(){ cr.backToday(); };
    this.find( this.caleTop.today_view_id ).onclick = function(){ cr.backToday(); };

// 'year and month select' onchange event
    this.find( this.caleTop.sq_year_id ).onchange = function(){ cr.updateSelect(); };
    this.find( this.caleTop.sq_month_id ).onchange    = function(){ cr.updateSelect(); };

// Quick link event
    this.find( this.caleTop.lq_year_id ).onclick = function(){
        cr.showHide( cr.caleTop.lq_year_id, "none" );
        cr.showHide( cr.caleTop.sq_year_id, "block" );
    };
    this.find( this.caleTop.lq_month_id ).onclick = function(){
        cr.showHide( cr.caleTop.lq_month_id, "none" );
        cr.showHide( cr.caleTop.sq_month_id, "block" );
    };

// Remove the link dotted line
    var oLink = this.find( this.caleContainer_id, "a" )
    for( var i = 0; i < oLink.length; i ++ ){
        oLink[i].onfocus = function(){ this.blur(); }
    }
}
/* Bind calendar for calendar view */
Calendar.prototype._initCalendar = function(){
    this._bindAllEvent();
    this._bindAllData( this.Year, this.Month );
};
/* Change the quick select value */
Calendar.prototype.changeSelectValue = function( year, month ){
    var ymArray = [], selectArray = [], linkArray = [];
    // Store the 'year' and 'month' to Array
    ymArray[0] = year; ymArray[1] = month + 1;

// Store the 'selectYear_id' and 'selectMonth_id' to Array
    selectArray[0] = this.caleTop.sq_year_id; selectArray[1] = this.caleTop.sq_month_id;

linkArray[0] = this.caleTop.lq_year_id; linkArray[1] = this.caleTop.lq_month_id;

for( var i = 0; i < selectArray.length; i ++ ){
        var selectObject = this.find( selectArray[i] );
        // Get the return index
        var index = this._getOptionIndex( selectObject, ymArray[i] );
        // Reset the 'year', 'month' select and link value
        selectObject.options[index].selected = "selected";

this.find( linkArray[i] ).innerHTML = selectObject.value;
    }

this.resetLinkSelect();
};
/* Search next or previons month */
Calendar.prototype.goPrevOrNextMonth = function( obj ){
    var curMonthSelect = this.find( this.caleTop.sq_month_id );
    var curMonth = parseInt( curMonthSelect.value );
    var curYear = this.find( this.caleTop.sq_year_id ).value;
    // If 'next' get current month select + 1
    // If 'prev' get current month select - 1
    if( obj.id == this.caleTop.next_month_id )
        curMonthSelect.value = curMonth + 1;
    else
        curMonthSelect.value = curMonth - 1;

var getNowMonth = curMonthSelect.value - 1;
    if( getNowMonth == -1 && curMonth == 1)     getNowMonth = 0;
    if( getNowMonth == -1 && curMonth == 12 )     getNowMonth = 11;

this._bindAllData( curYear, getNowMonth );
};
/* If 'select:Year' and 'select:Month' change value update data */
Calendar.prototype.updateSelect = function(){
    var yearSelectValue     = this.find( this.caleTop.sq_year_id ).value;
    var monthSelectValue = this.find( this.caleTop.sq_month_id ).value;
    // Re-bind Panel Data
    this._bindAllData( yearSelectValue, monthSelectValue - 1 );

};
/* Back to taday: re-load '_bindAllData()' */
Calendar.prototype.backToday = function(){
    this._bindAllData( this.Year, this.Month );
};
/* Find the instance object or children of instance object by Id */
Calendar.prototype.find = function( elemId, childTag ){
    if( !childTag )
        // Return: object
        return document.getElementById( elemId );
    else
        // Return: object array
        return this.find( elemId ).getElementsByTagName( childTag );
};
/* Set element css */
Calendar.prototype.css = function( oId, selector ){
    var o = this.find( oId );
    selector['left']?o.style.left = selector['left']:"";
    selector['top']?o.style.top = selector['top']:"";
    selector['position']? o.style.position = selector['position']:"";
}
/* Check calendar show or hidden */
Calendar.prototype.showHide = function( objectId, dis ){
    return this.find( objectId ).style.display = dis;
};
/* Init the top quick menu link and select */
Calendar.prototype.resetLinkSelect = function(){
    this.showHide( this.caleTop.sq_year_id, "none" );
    this.showHide( this.caleTop.sq_month_id, "none" );
    this.showHide( this.caleTop.lq_year_id, "block" );
    this.showHide( this.caleTop.lq_month_id, "block" );
};
/* Put this calendar into the html of instance */
Calendar.prototype.show = function( msgData ){
    var obj = this.find( this.InstanceId );
    if( obj ){
        obj.innerHTML = this._getViewElement();
        // Init calendar event and data
        this._initCalendar();

// This function don't have 'close'
        this.showHide( this.caleTop.close_id, "none" );
        if( typeof msgData == 'object'){
            this.msgStore = msgData;
            this._initPopMsg( this.msgStore );
        }
    }
};
/* Init pop message */
Calendar.prototype._initPopMsg = function(){
    var cr = this;
    var selectYear = this.find( this.caleTop.sq_year_id ).value;
    var selectMonth = this.find( this.caleTop.sq_month_id ).value;
    var daysOfMonthArray = this._getMonthViewArray( selectYear, selectMonth );
    var spans = this.find( this.daysContainer_id, "span" );
    for( var key in this.msgStore ){
        var keyMD = key.substring( 4 );
        var keyY = key.substring( 0, 4 );
        for( var i = 0; i < spans.length; i ++){
            var getMD = selectMonth + "" + spans[i].innerHTML;
            if( getMD == keyMD ){
                if( selectYear == keyY )
                    spans[i].className = this.tipDayClass +" "+ keyY;
                else
                    spans[i].className = this.oldTipDayClass +" "+ keyY;    
                spans[i].onmouseover = function(){
                    var hoverDate = this.className.split(" ")[1] + "" + selectMonth + "" + this.innerHTML;
                    var y = this.className.split(" ")[1],
                        m = selectMonth,
                        d = this.innerHTML;
                    cr.find( cr.msgContainer_id ).innerHTML = cr._getMsgHtml( y, m, d );
                    cr.showHide( cr.msgContainer_id, "block" );
                }
            }
        }
    }
    cr.find( cr.caleContainer_id ).onmouseout = function(){
        cr.showHide( cr.msgContainer_id, "none" );
    }
};
/* Get message */
Calendar.prototype._getMsgHtml =function( y, m, d ){
    var date = y + m + d;
    var showDate = y + "-" + m + "-" + d;
    var msgHtml = '<div>'+showDate+':</div><div>'+ this.msgStore[date] +'</div>';
    return msgHtml;
}
/* Pop-up the calendar */
Calendar.prototype.pop = function(){
    var cr = this;
    var obj    = this.find( this.InstanceId );
    if( obj ){
        // Instance object click then pop-up the calendar
        obj.onclick = function( e ){
            var e = window.event || e;
            var x = e.x || e.pageX,
                y = e.y || e.pageY;
            if( !cr.find( cr.popContainer_id ) ){
                // Create the pop-up div
                var oDiv = document.createElement("div");
                oDiv.id = cr.popContainer_id;
                document.body.appendChild( oDiv );
            }else{
                cr.showHide( cr.popContainer_id, "block" );
            }
            cr.find( cr.popContainer_id ).innerHTML = cr._getViewElement();

// Init calendar event and data
            cr._initCalendar();

// Set days click event
            cr.popDaysClickEvent( obj );

// Set position
            cr.css( cr.popContainer_id, {position: "absolute", left: x + "px", top: y + "px"});

// Close panel event
            cr.find( cr.caleTop.close_id ).onclick = function(){ cr.showHide( cr.popContainer_id, "none" ); };
        };
    }
};
/* Click the pop calendar days event [For INPUT] */
Calendar.prototype.popDaysClickEvent = function( obj ){
    var cr = this;
    var spans = cr.find( cr.daysContainer_id, "span" );
    for( var i = 0; i < spans.length; i ++ )
        spans[i].onclick = function(){
            if( this.innerHTML != " " ){
                var getYear     = cr.find( cr.caleTop.sq_year_id ).value;
                var getMonth = cr.find( cr.caleTop.sq_month_id ).value;
                obj.value = getYear +"-"+ getMonth +"-" + this.innerHTML;
                cr.showHide( cr.popContainer_id, "none" );
            }
        }
};

(0)

相关推荐

  • 支持IE,Firefox的javascript 日历控件

    效果图:其实学习的方法,就是会搜索的方法,会搜索才能更快的解决问题.搜索方法: javascript 日历控件 site:jb51.net| 日期输入框演示-jb51.net script body{font-size:12px;font-family:Verdana,Arial,"宋体";} a:link {color:#464646;text-decoration:none;} a:visited {color:#464646;text-decoration:none;}ifram

  • php+javascript的日历控件

    复制代码 代码如下: <html> <head> <title>js calendar</title> <script language="javascript"> /* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo * ----------------------------------------------------------- * * The DHT

  • javascript实现的淘宝旅行通用日历组件用法实例

    本文实例讲述了javascript实现的淘宝旅行通用日历组件用法.分享给大家供大家参考. 在线演示:http://demo.jb51.net/js/2015/trip-calendar/demo.html PS:下面的演示代码,需要用到 trip-calendar.js与trip-calendar.css文件.打包下载地址 具体如下: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8">

  • javascript实现的简易的DatePicker日历

    jQ的ui有,YUI的widget里也有.而且也封装的结结实实,兼容性,通用性,都做得挺好.于是在代码完善的同时,代码量自然也不会少.即使建立在基础库之上,代码也是好几百行. 真正使用的时候可能并不需要这么完善的功能.咱们就写个简陋点的东西,够自己用就行了. 而且以前有朋友提出我发的东西都是一些娱乐货,没有什么实用性,这次就当是个开始,抛个砖,以后时不时发个带一些实用性的东东. <!-- 以下demo没有什么出彩的地方,仅供有需要的朋友看看 --> DatePicker .date-picke

  • JavaScript日历实现代码

    效果如下:javascript 代码如下: 复制代码 代码如下: var Calendar = function(){ var self = this; self.box = document.createElement("div"); self.head = document.createElement("div"); self.datePlace; self.body = document.createElement("div"); self

  • 由Javascript实现的页面日历

    效果图:CSS代码: 复制代码 代码如下: <style type="text/css"> *{ margin:0; padding:0; font:10px tahoma; } #calender{ text-align:center; width:147px; font-size:10px; /*color: #27B0C1;*/ margin:12px 0 12px 6px; border-top:1px solid #EEEEEE; border-left:1px

  • 纯javascript制作日历控件

    以前要用到日历控件都是直接从网上下载一套源码来使用,心里一直有个梗,就是想自己动手写一个日历控件,最近刚好来了兴趣,时间上也允许,于是自己摸索写了一个,功能还算完善,界面就凑合了.可能最值得说的一点就是让input控件内部右边显示一个按钮,我是直接给input加了个背景,然后把input的边框去掉实现的. 这个是最初版的,再往后打算做出纯javascript版的,再往后打算用JQuery做一套. <!doctype html> <html> <head> <met

  • JavaScript blog式日历控件新算法

    使用说明: 程序比较简单,代码中都有说明,这里说说怎么使用. 首先是实例化一个Calendar,并设置参数. 参数说明: Year:要显示的年份 Month:要显示的月份 SelectDay:选择日期 onSelectDay:在选择日期触发 onToday:在当天日期触发 onFinish:日历画完后触发 一般SelectDay设置成选择了的日期,并在onSelectDay中设置一个函数用来设置这个日期的样式, 例如实例里SelectDay设置成今个月10号并在那天样式设为onSelect: 复

  • javascript实现淘宝幻灯片广告展示效果

    本文实例讲述了javascript实现淘宝幻灯片广告展示效果的方法.分享给大家供大家参考.具体如下: 一.效果图如下: 二.代码部分: JS代码部分: function getClass(oParent,name){ var arr=[]; var oBj=oParent.getElementsByTagName("*"); for(var i=0;i<oBj.length;i++){ if(oBj[i].className==name){ arr.push(oBj[i]); }

  • javascript 日历提醒系统( 兼容所有浏览器 )

    功能介绍: 1.正常的日历功能. 2.等等等 3.接收 数组 例如: 复制代码 代码如下: new Calendar("id").show( { "20091120": "今天干了嘛嘛...", "2009320": "今天干了嘛嘛..." } ); 日历提示样式分为3类. a. 当日 b.当年当月当日提示样式 c.当月当日提示样式 鼠标覆盖在有提示的日期上自动出现提示内容 4...... 主要分为2种用处

  • javascript 开发之网页兼容各种浏览器

    javascript 开发之网页兼容各种浏览器 前言: 关于CSS对各个浏览器兼容已经是老生常谈的问题了, 网络上的教程遍地都是.以下内容没有太多新颖, 纯属个人总结, 希望能对初学者有一定的帮助. 一.CSS HACK 以下两种方法几乎能解决现今所有HACK. 1, !important 随着IE7对!important的支持, !important 方法现在只针对IE6的HACK.(注意写法.记得该声明位置需要提前.) <style> #wrapper { width: 100px!imp

  • Javascript iframe交互并兼容各种浏览器的解决方法

    在Web前端开发中,我们经常会用到iframe这个控件. 但是这个控在内.外交互时,往往各个浏览器所用的关键字不同,很是麻烦,为了能够得到子iframe中的window对象,各家浏览器有着各家的指定,有的是window,有的是contentWindow等等也许还有我们不知道的. 但是从子页面访问父层页面,其本上大家都是window.parent就可以了. 那么通过这个特征,我们可以在子页面中,把自身的window对象传递给父页面就可以了,这样父页面就很轻松的访问子页面,再也不用靠虑如何从ifra

  • JavaScript自定义DateDiff函数(兼容所有浏览器)

    复制代码 代码如下: <script type="text/javascript"> function NewDate(str) { str = str.split('-'); var date = new Date(); date.setUTCFullYear(str[0], str[1] - 1, str[2]); date.setUTCHours(0, 0, 0, 0); return date; } function TimeCom(dateValue) { var

  • JavaScript 复制功能代码 兼容多浏览器

    因此兼容性没得说了,现在用不上的话,先收藏一下吧. JavaScript 复制功能代码,兼容多浏览器 //ie copyValue=function(strValue) { if(isIE()) { clipboardData.setData("Text",strValue); alert("您已成功复制了此地址"); } else { copy(strValue); alert("内容已被复制!"); } } function isIE(num

  • JavaScript 实现完美兼容多浏览器的复制功能代码

    分享一段利用 JavaScript 实现复制功能的代码,兼容多浏览器,兼容IE和火狐浏览器. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JavaScript 复制功能代码,兼容多浏览器&l

  • javascript 浏览器类型和版本号检测代码(兼容多浏览器)

    javascript检测浏览器类型和版本号(兼容各浏览器) var uA = navigator.userAgent; var browserType = "unknown"; if (uA.indexOf("Opera") > -1) { browserType = "Opera"; } else if (uA.indexOf("Safari") > -1) { browserType = "Safar

  • javascript获取设置div的高度和宽度兼容任何浏览器

    Javascript如何获取和设置div的高度和宽度,并且兼容任何浏览器?看代码: 复制代码 代码如下: <div id="div1" style="height:300px;width:200px;">http://www.itdos.com</div> <div id="div2" style="height:30px;width:20px;">http://www.itdos.com&

  • 基于javascript代码检测访问网页的浏览器呈现引擎、平台、Windows操作系统、移动设备和游戏系统

    废话不多说了,直接给大家贴js代码了,代码附有注释,感兴趣的朋友一起学习吧. /** * Author: laixiangran. * Created by laixiangran on 2015/12/02. * 检测访问网页的浏览器呈现引擎.平台.Windows操作系统.移动设备和游戏系统 * ******************************************************************** * 各版本浏览器在windows10.0下的用户代理字符串:

  • javascript实现客户端兼容各浏览器创建csv并下载的方法

    本文实例讲述了javascript实现客户端兼容各浏览器创建csv并下载的方法.分享给大家供大家参考.具体实现方法如下: $("#radarDLBut").click(function(){ var data = [displayData["radar_chart"]["r_label"],displayData["radar_chart"]["r_default"]]; var csvContent =

随机推荐