随笔分类 - javascript
解析为日期格式
摘要:/** * 将目标字符串转换成日期对象 * @name baidu.date.parse * @function * @grammar baidu.date.parse(source) * @param {string} source 目标字符串 * @remark * 对于目标字符串,下面这些规则决定了 parse 方法能够成功地解析: <br><ol><li>短日期可以使用“/”或“-”作为日期分隔符,但是必须用月/日/年的格式来表示,例如"7/20/96"。</li><li>以 "July 10 1
阅读全文
posted @ 2013-03-01 15:08
狐狸v
Js验证Email电话
摘要:<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" charset="utf-8"></script><form method="post" action="http://mail.163.com" id="myform" > <input type="text" nam
阅读全文
posted @ 2013-03-01 15:07
狐狸v
Jquery问题mouseout事件
摘要:divA里面有个divB,然后在divA加上鼠标移出事件,现在是鼠标移到divB的区域时,divA也隐藏了.$("#divA").mouseout(function(){ $(this).hide();});<div id='divA'>a<div id='divB'>b</div></div>解决方法:mouseenter和mouseleave事件就是防止这种情况出现而使用的$("#divA").mouseleave(function(){ $(this).hide();}
阅读全文
posted @ 2013-03-01 15:06
狐狸v
距离**还有几天
摘要:/*距离**还有几天HowLongSince(11,10,2002);*/function HowLongSince(startmonth, startdate, startyear) { var sdate=startdate;<!--获得开始的日期--> var smonth=startmonth-1;<!--获得开始的月份--> var syear=startyear;<!--获得开始的年份--> var DaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);<!--每个月中包含
阅读全文
posted @ 2013-03-01 15:05
狐狸v
Js跟随工具条
摘要:<script type="text/javascript"> $(function(){ if (!($.browser.msie && parseInt($.browser.version) == 6)){ $(window).scroll(function () { //相关方法 $(window).scrollTop() $(window).height() $("#lookMore").offset().top ...
阅读全文
posted @ 2013-03-01 15:05
狐狸v
跨域取数据的方法
摘要:跨域请求的方式有很多种,1,iframe2,document.domain3,window.name4,script5,XDomainRequest (IE8+)6,XMLHTTPRequest (Firefox3.5+)7,postMessage (HTML5)8,后台代理...1.jsonp其实 jsonp 是个很简单的一个东西。主要是利用了 <script/> 标签对 javascript 文档的动态解析来实现。(其实也可以用eval函数)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
阅读全文
posted @ 2013-03-01 15:04
狐狸v
预加载图片
摘要://定义预加载图片列表的函数(有参数)jQuery.preloadImages = function(){ //遍历图片 for(var i = 0; i<arguments.length; i++){ jQuery("<img>").attr("src", arguments[i]); }}// 你可以这样使用预加载函数$.preloadImages("images/logo.png", "images/logo-face.png", "images/mission.png"
阅读全文
posted @ 2013-03-01 15:03
狐狸v
JavaScript中base64
摘要:http://baike.baidu.com/view/469071.htmlvar Base64 = { // private property _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode: function(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; ...
阅读全文
posted @ 2013-03-01 15:02
狐狸v
保留小数位
摘要://保留小数位function formatNumber(val, fixed) { return new Number(val).toFixed(fixed);}
阅读全文
posted @ 2013-03-01 15:01
狐狸v
动态加载新的js文件
摘要://加载新的jsfunction _GetJsData(url, callback) { var scripts = document.createElement("script"); document.body.appendChild(scripts); scripts.onload = function() { callback(); document.body.removeChild(this); }; scripts.onreadystatechange = function() { if (this.readyS...
阅读全文
posted @ 2013-03-01 15:00
狐狸v