随笔分类 - JavaScript
摘要:backbone版本:0.9.21.解析Backbone.Model(Collection | Router | View).extend(1).找到extend的定义 //定义extend函数varextend=function(protoProps,classProps){/*通常我们以Backbone.XXX.extend的方式建立一个Model、View等对象类型,所以在此处this表示Backbone.Model、Backbone.View等对应构造函数(注:后面的类似概述统一以Backbone.View为具体例子)*/varchild=inherits(this,protoProp
阅读全文
摘要:function submitFun() { var files = [document.getElementById('sc')]; ajaxUploadFile({url:'Index.aspx','files':files,success:function(){alert('success');}}); } //{url, files, data,success,error} function ajaxUploadFile(ajaxOptions) { var iframeName = 'tmp_iframe'
阅读全文
摘要:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
阅读全文
摘要:/***创建一个遮盖层*id:遮盖层的id,如果为null,则自动生成一个id*cssObj:遮盖层的样式对象,也可以是一个类名*opacity:一个0-1之间的小数,表示透明度,数字越小透明度越高*/functionLock(id,cssObj,opacity){Lock.num=Lock.num||1;Lock.num++;//当前遮盖层的idvarlockID=id||'divlock_'+Lock.num;//默认样式cssObj=cssObj||{backgroundColor:"black",filter:"alpha(Opacity=
阅读全文
摘要:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
阅读全文
摘要:火狐:ClientWidth和ClientHeight:包括width,height和对应的paddingoffsetWidth和offsetHeight:包括width,height和对应的padding,以及对应的borderscrollWidth和scrollHeight:包括width,height和对应的padding,以及对应的borderchrome:ClientWidth和ClientHeight:包括width,height和对应的paddingoffsetWidth和offsetHeight:包括width,height和对应的padding,以及对应的borderscro
阅读全文
摘要:<html xmlns="http://www.w3.org/1999/xhtml"><head> <title>JavaScript实现的可以拖动排版可以关闭的DIV层丨芯晴网页特效丨CsrCode.Cn</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> body { margin: 0p
阅读全文
摘要:functionDrawImage(ImgD,iwidth,iheight){varimage=newImage();image.src=ImgD.src;if(image.width>0&&image.height>0){flag=true;if(image.width/image.height>=iwidth/iheight){if(image.width>iwidth){ImgD.width=iwidth;ImgD.height=image.height*iwidth/image.width;}else{ImgD.width=image.width
阅读全文
摘要:function Exec(funcName, arr, byResult) { if (byResult) { if (typeof funcName == "string") { if (window[funcName]) { //如果返回false或者没用返回值,则继续执行一次,知道返回true if (!window[funcName](arr)) { window.setTimeout(function() { Exec(funcName, arr, true) }, _interval); } } else { window.setTimeout(function() { Exec
阅读全文
摘要:test.html如下:!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"htmlhead id="head" meta http-equiv="Content-Type" content="text/html; charset=utf-8" / titletest/title style type='text/css' img { border: 1px solid red; d
阅读全文
摘要:!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"htmlhead id="head"meta http-equiv="Content-Type" content="text/html; charset=utf-8" /title向上下左右不间断无缝滚动图片的效果(兼容火狐和IE)/titlestyle type='text/css' img{border:1px solid re
阅读全文
摘要:对IE8和Firefox3.6测试结果:1.常规的在head里面使用Script标签引用js,不再是堵塞模式加载(也就是说脚本文件不再是一个一个被加载,加载完成一个才开始加载另一个),而是最大6个JS同时开始加载(并发限制为6个),但是script的执行顺序还是按照Script标签顺序,而且会阻碍页面的呈现。2.由于1的原因,所以使用document.write("script.../script")(此方式对Firefox无效)的方式和head.append(script)(此方式兼容IE和Firefox)的方式使用异步加载意义不大3.但是使用head.append(script)的
阅读全文
摘要:String.Format = function(str) { var reg; var args; //自定义一个undifined,增快速度 var undifined; if (arguments[1] && typeof (arguments[1]) == "object") { reg = new RegExp("\\{([^\\d]\\w*)\\}", "g"); args = arguments[1]; } else { reg = new RegExp("\\{(\\d+)\\}","g"); //将arguments转换成数组然后赋值给args args = Array.pr
阅读全文
摘要:%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Reg.aspx.cs" Inherits="YXShop.Web.Reg" %%@ Register Src="UserControls/NavControl.ascx" TagName="NavControl" TagPrefix="ucNav" %%@ Register Src="UserControls/LeftSeriesControl.ascx" TagName="LeftSeriesControl" TagPrefix="ucLeft" %!DOCTYP
阅读全文
摘要:functiongetCurrentStyle(ele,name){if(typeof(ele)=="string"){ele=document.getElementById(ele);}if(document.all){returnele.currentStyle[name];}returndocument.defaultView.getComputedStyle(ele,null)[name];}functionupdate(){show("layer");}//弹出层functionshow(divID,relativeTop,relativeLe
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>test</title> <style type="tex
阅读全文
摘要:var arr=eval("[1,2,5]"); alert(arr[2]) /*有效 var mm={"age":99}; alert(mm.age); */ /*有效 eval('var mm={age:123}'); alert(mm.age); */ /*有效,属性名可以不加引号,但是一定要在字符串最外面加上 ( ) var mm= eval("({age:66,name:\"mxw\"})"); alert(mm.name)*/
阅读全文
摘要:replace() 方法的参数 replacement 可以是函数而不是字符串。在这种情况下,每个匹配都调用该函数,它返回的字符串将作为替换文本使用。该函数的第一个参数是匹配模式的字符串。接下来的参数 是与模式中的子表达式匹配的字符串,可以有 0 个或多个这样的参数。接下来的参数是一个整数,声明了匹配在 stringObject 中出现的位置。最后一个参数是 stringObject 本身。 下文展示了几种javascript正则表示式的repalce方式,有些方式我们很少在别的地方看到,如第二种和第三方中方法。 //下面的例子用来获取url的两个参数,并返回urlRewrite之前的真实
阅读全文
摘要:function GetEle(obj, IsPre, nodeName) { if (IsPre) { if (obj.previousSibling.nodeName.toLowerCase() == nodeName.toLowerCase()) { return obj.previousSibling; } return GetEle(obj.previousSibling, IsPre, nodeName); } else { if (obj.nextSibling.nodeName.toLowerCase() == nodeName.toLowerCase()) { return
阅读全文