话说回来,虽然jQuery让学习前端技术的越来越多了起来,(本人就是因为学校图书馆偶然间遇到了一本jQuery基础教程(二)开始想深入的学习前端技术),关于jQuery的博文甚至多于javascript,它让编程的门槛大大的降低了,但是它隐藏了太多细节了,形如$('#id').append('xxx').clone().appendTo(x).end().css(...)................这样操作的模式已经很难找到常规javascript的影子。浏览器的差异仿佛一去就不见了踪影,我不认为大部分...
jQuery式的方法链核心部分是三点: 1)jquery的包装器函数(也就是jQuery(),以此来构建包装器对象),以此构造函数可以产生饱含了原生DOM对象的包装器对象。 它大概是这个样子的…(当然跟官方库的规模跟功能以及实现方式都差很多,我只是写了个大概的实现方式): 呃…………我的失误,请大家如果有兴趣尝试下代码记得不要引入jQuery库,命名冲突了 代码如下: (function(){ //简化起见不支持子类选择器属性选择器等等,只接受形如".cla...
一、父窗口调用iframe子窗口方法 1、HTML语法: 2、父窗口调用子窗口:myFrame.window.functionName(); 3、子窗品调用父窗口:parent.functionName(); 简单地说,也就是在子窗口中调用的变量或函数前加个parent.就行 4、父窗口页面源码: 代码如下: function say() { alert("parent.html----I'm at parent.html"); } function callChild() { //document.frames("myFrame").f1(); myFrame.window.say(); } 5、子窗口页面...
一、方法体内返回对象实例自身(this) 代码如下: function ClassA(){ this.prop1 = null; this.prop2 = null; this.prop3 = null; } ClassA.prototype = { method1 : function(p1){ this.prop1 = p1; return this; }, method2 : function(p2){ this.prop2 = p2; return this; }, method3 : function(p3){ this.prop3 = p3; return this; } } 定义了function/类ClassA。有三个属性/字段prop1,prop2,prop3,三个方法methed1,method2...
本文介绍的是嵌入在.Net的WebBrowser控件中显示的HTML文件中的Javascript如何调用C#代码。现在在客户端程序中嵌入网页的做法已经非常普遍了,例如腾讯的新闻弹出框之类的。 .Net的WebBrowser用的内核应该还是IE的。IE中,window对象有个external属性,这个属性提供了一个外部接口。可以执行宿主代码。要通过这个属性来调用C#方法,其宿主对象必须是ComVisible的。例如,我们在一个Form上放置一个WebBrowser控件,另外准备一个方法O...
从网易撬过来的js调用广告显示文件 只有下面短短几行代码可以随机显示flash和gif广告,还不错 代码如下:function column02(imgSource,url,chance,type) { this.imgSource = imgSource; this.url = url; this.chance = chance; this.type = type; } function dispColumn02() { with (this) switch (type){ case "img": document.write(""); break; case "html": document.write(""); break; case "flash": document.write(""); bre...
个人感觉有两点是比较方便的:第一,在对WebService做ajax请求的时候,请求的url的写法是:服务地址/调用的方法名称,这样在请求的url中就确定了要调用的方法了,不必再在WebService代码中去判断ajax请求调用的是哪个方法了。第二,方法可以返回更多的数据类型,比如对象,泛型集合等;在ajax请求返回后,会自动将这些类型转换为json对象。而使用ashx的方式的话,需要先将这些类型转换为json格式的数据才能返回。 在使用jQuery...
方式1 代码如下: function Person(n,a){ this.name = n; this.age = a; if(this instanceof Person){ alert(new调用); }else{ alert(函数调用); } } var p = new Person(jack,30); // --> new调用 Person(); // --> 函数调用 方式2 代码如下: function Person(n,a){ this.name = n; this.age = a; if(this instanceof arguments.callee){ alert(new调用); }else{ alert(函数调用); } } var p = new Person(jack,30); // --> new...
一、对象链:方法体内返回对象实例自身(this) 代码如下: function ClassA(){ this.prop1 = null; this.prop2 = null; this.prop3 = null; } ClassA.prototype = { method1 : function(p1){ this.prop1 = p1; return this; }, method2 : function(p2){ this.prop2 = p2; return this; }, method3 : function(p3){ this.prop3 = p3; return this; } } 定义了function/类ClassA。有三个属性/字段prop1,prop2,prop3,三个方法methed1...
一个例子说尽: 1、.aspx中: 代码如下: HelloWorld 传入参数 返回集合 返回复合类型 返回DataSet(XML) 服务器处理中,请稍后
首选创能wcf,代码很简单,如下: 代码如下: using System; using System.Data; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Web.Script.Services; [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(IncludeExceptionDetailInFaults = true)] publi...
HTML 端: PART 1: 代码如下: {{foreach from=$question.question_item item="it" name="question_item"}} {{$it.item_id}} {{$it.item_name}} 9 {{/foreach}} PART 2: 代码如下: JS 文件: 代码如下: function createSWF(swfHome,swfHeight) { if(swfobject.hasFlashPlayerVersion("9")) { var flashvars = {}; flashvars.quesID = swfHome; swfobject.embedSWF("swf/statistic2.swf",swfHome,"520",swfHeight,"9","...
代码如下: function GetDIVORPIV(DIV) { var str; var arrayDIV=new Array(); if(DIV.indexOf("_")>0) { arrayDIV=DIV.split("_"); str=arrayDIV[1]; } else { str=""; } return str; } function GetDIVandPIV(DIVPIV) { var strDIVandPIV; var strDIVPIV=DIVPIV; var arrayDIVPIV=new Array(); if(strDIVPIV.indexOf("&")>0) { arrayDIVPIV=strDIVPIV.split("&"); strDIVandPIV=GetDIVORPIV(arrayDIVPIV[0])+GetDIVORPIV(arrayDIV...
方法调用模式 当一个函数被保存为对象的一个属性时,我们称之它为该对象的一个方法,那么this被绑定到该对象上。 代码如下: var myObject={ name : "myObject" , value : 0 , increment : function(num){ this.value += typeof(num) === number ? num : 0; } , toString : function(){ return [Object:+this.name+ {value:+this.value+}]; } } alert(myObject);//[Object:myObject {value:0}] 函数调用模式 当一个函数并非一个对...
前言 大家学JavaScript的时候,经常遇到自执行匿名函数的代码,今天我们主要就来想想说一下自执行。 在详细了解这个之前,我们来谈了解一下“自执行”这个叫法,本文对这个功能的叫法也不一定完全对,主要是看个人如何理解,因为有的人说立即调用,有的人说自动执行,所以你完全可以按照你自己的理解来取一个名字,不过我听很多人都叫它为“自执行”,但作者后面说了很多,来说服大家称呼为“立即调用的函数表达式”。 本文英文原文...