String.prototype.trim = function() { return this.replace(/^s+|s+$/g,""); } String.prototype.ltrim = function() { return this.replace(/^s+/,""); } String.prototype.rtrim = function() { return this.replace(/s+$/,""); }
Prototype.js中bind方法的源码
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return function(){ return fn.apply(object, args.concat(Array.prototype.slice.call(arguments))); }; };
AJAX前进后退按钮失效,及刷新问题的解决方案
function hashChange(){ var m=window.location.hash.split('#'); m=m[1]?m[1].split('=')[1]:0;//获取到锚点的参数值 if(m){ $.post(App_path,{type:type},function(){//将锚点参数提交到后台处理,返回所需信息 //do some thing here }) } } $(window).hashchange(function(){ hashChange(); })