源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

风吟的小型JavaScirpt库 (FY.JS).

  • 时间:2022-08-23 04:58 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:风吟的小型JavaScirpt库 (FY.JS).
小弟刚学javascript没几天不发出来给各位高手指教看看这个小库哪方面可以做的更好实在是不会进步,于是我发出来求喷来了。这个小玩意我开发的初衷就是给自己使用的不建议大家使用。你要是觉得风吟的代码写得不好请你耐心的照顾一下我这个小菜鸟务必跟我说明白哪里不好应该怎么改。我不是重造轮子我只是想提高自己的水平。希望不吝赐教。 比如此库什么地方还可以更精简的写法节省更多代码 比如此库哪里不兼容或者如何写法更完美。  FY.JS已经在google code 上存放.  项目地址:[url=http://code.google.com/p/fyjs/]http://code.google.com/p/fyjs/[/url]   文档地址:[url=http://fyjs.googlecode.com/files/FY.JS.1.0.doc.zip]http://fyjs.googlecode.com/files/FY.JS.1.0.doc.zip[/url]  (文档地址,里面含有完整例子.)  文件地址:[url=http://fyjs.googlecode.com/files/FY.1.0.js]http://fyjs.googlecode.com/files/FY.1.0.js[/url]  (压缩版1.54KB) 源代码经过格式化的...
[u]复制代码[/u] 代码如下:
/* * FY Library 1.0 * Copyright(c) 2010 FengYin * Blog: http://fengyin.name/ * Date: 2010-3-12 16:10:01 * Update: http://code.google.com/p/fyjs/ */ (function(_w,_d) { var _FY,$,FY; _w._FY=_w.$= function(i) { return new FY(i) }; FY = function(i) { this.id = _d.getElementById(i) }; FY.prototype = { ready: function(f) { var l = _w.onload; if (typeof(l) == "function") { _w.onload = function() { l(); f() } } else { _w.onload = f } }, html: function(c) { var g = this.id, r = g.innerHTML; if (c) { g.innerHTML = ""; g.innerHTML += c; return this } else { return r } }, val: function(c) { var g = this.id, r = g.value; if (c) { g.value = ""; g.value += c; return this } else { return r } }, text: function(c) { var g = this.id, r = g.innerText, f = g.textContent; if (c) { r ? g.innerText = "": g.textContent = ""; r ? g.innerText += c: g.textContent += c; return this } else { return r ? r: f } }, show: function(f) { this.id.style.display = "block"; f ? f() : null }, hide: function(f) { this.id.style.display = "none"; f ? f() : null }, bind: function(t, f) { var l = this.id, e = l.attachEvent; e ? l.attachEvent("on" + t,f):l.addEventListener(t,f,false) }, setcookie: function(s) { var p = new Date(); p.setTime(p.getTime() + (s.expires || 24) * 60 * 60 * 1000); _d.cookie = s.name + "=" + escape(s.value) + ";expires=" + p.toGMTString() + ';path=/' }, getcookie: function(n) { var c = _d.cookie.match(new RegExp("(^| )" + n + "=([^;]*)(;|$)")); return c ? unescape(c[2]) : null }, ajax: function(s) { var a = _w.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); with(a) { open("POST", s.url, true); setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); send(s.data); onreadystatechange = function() { if (readyState == 4 && status == 200) { s.success(responseText) } } } } } })(window,document);
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部