摘要:
先看一个示例用javascript获取url网址信息<script type="text/javascript">document.write("location.host="+location.host+"<br>");document.write("location.hostname="+location.hostname+"<br>");document.write("location.href="+location.href+&qu 阅读全文
随笔分类 - web---JavaScript
javascript 和ajax创建bookmarket
2012-09-02 00:39 by youxin, 443 阅读, 收藏,
摘要:
Create easy-to-maintain bookmarklets of arbitrary size.A bookmarklet is a special piece of JavaScript code that can be dragged into a user's Links toolbar and later clicked on to implement cross-site behavior. Bookmarklets have size limitations, which differ based on browser and platform, since 阅读全文
bulletproof ajax 05: hijax
2012-09-01 15:49 by youxin, 350 阅读, 收藏,
摘要:
THE HIJAX APPROACHI’d like to introduce you to a methodology I call Hijax. It’s a two-step plan forbuilding Ajax applications that degrade gracefully:1. Begin by building a regular Web page. The user can request informationfrom and send information to the server using links and forms. The server ret 阅读全文
bulletproof ajax:ajax 载入时显示动画
2012-09-01 14:22 by youxin, 303 阅读, 收藏,
摘要:
The simplest format for this kind of image is an animated GIFfile. The exact image can be anything you like, as long as it featuresa smoothly looping animation. Rotating shapes, spinningarrows, and barbershop-pole progress bars are all popular conventionsfor indicating activity.Here’s a short functi 阅读全文
javascrit string split escape()
2012-08-30 23:59 by youxin, 231 阅读, 收藏,
摘要:
Split a string into an array of substrings:string.split(separator,limit) limit表示最大的数组元素个数。:If an empty string ("") is used as the separator, the string is split between each character.Use a letter as a separator:var str="How are you doing today?";var n=str.split("o");Th 阅读全文
javascript权威指南:javascript 变量
2012-08-30 22:08 by youxin, 249 阅读, 收藏,
摘要:
If you don't declare a variable explicitly, JavaScript will declare it implicitly for you.var i;var sum; You can also declare multiple variables with the same var keyword:var i, sum; It is legal and harmless to declare a variable more than once with the var statement. If the repeated declaration 阅读全文
Type-ahead (auto-complete) suggest 开发
2012-08-30 01:00 by youxin, 366 阅读, 收藏,
摘要:
Since Ajax has become popular, the type-ahead suggest has been one of the mostsought-after pieces of code. Many people have created different versions of thetype-ahead suggest that handle the interaction with the server in many ways. A lotof the solutions out there have flaws, while others go way ov 阅读全文
Json简介
2012-08-29 16:15 by youxin, 278 阅读, 收藏,
摘要:
JSON(JavascriptObjectNotation)是一种轻量级的数据交换语言,以文字为基础,且易于让人阅读。尽管JSON是在Javascript的一个子集,但JSON是独立于语言的文本格式,并且采用了类似于C语言家族的一些习惯。JSON用于描述数据结构,有以下形式存在。来自wikipedia:http://zh.wikipedia.org/wiki/JSON对象 (object):一个对象以“{”开始,并以“}”结束。一个对象包含一系列非排序的名称/值对,每个名称/值对之间使用“,”分区。名称/值对(collection):名称和值之间使用“:”隔开,一般的形式是{name:valu 阅读全文
bulletproof ajax: Data Formats
2012-08-29 15:46 by youxin, 299 阅读, 收藏,
摘要:
Ajax is language agnostic, at least on the server. It doesn’t matter what server-side language you use for your business logic. However, when you are requesting data from the server,the data that’s sent from the server must be formatted in a waythat the browser can understand. Your server-side progr 阅读全文
bulletproof ajax: XMLHttpRequest
2012-08-29 01:29 by youxin, 362 阅读, 收藏,
摘要:
ajax作者发表的论文:http://www.adaptivepath.com/ideas/ajax-new-approach-web-applicationsThe Ajax ToolkitThe XMLHttpRequest object is the engine that drives Ajax, but it doesn’texist in a vacuum. As Jesse James Garrett said in his original essay, “Ajax isn’t a technology. It’s really several technologies, ea 阅读全文
javascript 与 ajax
2012-08-28 19:33 by youxin, 292 阅读, 收藏,
摘要:
AJAX = Asynchronous JavaScript and XML.AJAX is not a new programming language, but a new way to use existing standards.AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.http://www.w3schools.com/ajax/ajax_intro.aspAjax involves the u 阅读全文
javascript Dom 编程艺术:ANIMATED SLIDESHOW
2012-08-28 16:41 by youxin, 505 阅读, 收藏,
摘要:
Animation is the perfect example of this kind of change. In a nutshell, animation involveschanging an element’s position over time.IncrementsMoving an... 阅读全文
Javascript DOM 编程艺术:Css-dom
2012-08-28 16:22 by youxin, 300 阅读, 收藏,
摘要:
Three sheets to the WebContent on the Web can be wrapped up in three successive layers that are readable byweb browsers:StructurePresentationBehaviorThe style propertyEvery element in a document is an object. Every one of these objects has a whole collectionof properties. Some properties contain inf 阅读全文
javascript里的document.all用法
2012-08-28 13:20 by youxin, 376 阅读, 收藏,
摘要:
all 方法最初是由 IE 浏览器拥有的,并不属于 W3C 规范范畴,他返回调用 all 方法的 HTML 标记自身内的所有子孙元素的 HTML 标记集合 。all 方法的详细说明请参见 MSDN:http://msdn.microsoft.com/en-us/library/ms537434(VS.85).aspx。通常情况下使用 document.all 方法获得文档元素内所有 HTML 标记的集合,他最先使用在 IE 浏览器中。现在其他浏览器已经支持 document.all 这个方法了,但在支持细节上有差异。在 IE 中 document.all 的布尔值是 true ,其他浏览器都是 阅读全文
javascript Event对象详解
2012-08-28 13:08 by youxin, 364 阅读, 收藏,
摘要:
Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.Event代表事件状态,如事件发生的元素,键盘状态,鼠标位置和鼠标按钮状态。一旦事件发生,便会生成Event对象,如单击一个按钮,浏览器的内存中就产生相应的 event对象。event对象只在事件发生的过程中才有效。event的某些属性只对特定的 阅读全文
转:JavaScript中绑定事件监听函数的通用方法
2012-08-28 01:05 by youxin, 346 阅读, 收藏,
摘要:
事件绑定的3中常用方法:传统绑定、W3C绑定方法、IE绑定方法。但是,在实际开发中对于我们来讲重要的是需要一个通用的、跨浏览器的绑定方法。如果我们在互联网上搜索一下会发现许多方法,一下是比较知名的几种方法:在开始学期下面几种方法之前,应当讨论一下,一个好的addEvent()方法应当达到哪些要求: a、支持同一元素的同一事件句柄可以绑定多个监听函数; b、如果在同一元素的同一事件句柄上多次注册同一函数,那么第一次注册后的所有注册都被忽略; c、函数体内的this指向的应当是正在处理事件的节点(如当前正在运行事件句柄的节点); d、监听函数的执行顺序应当是按照绑定的顺序执行; e、在函... 阅读全文
javascript闭包
2012-08-28 00:45 by youxin, 196 阅读, 收藏,
摘要:
ecmascript最让人误解的一点是他支持闭包。所谓闭包,是指词法表示包括不必计算的变量的函数。也就是说,该函数能使用函数外定义的变量。在ecmascript中使用全局变量时一个简单的闭包实例:var sMessage="hello world";function sayHelloWorld(){ alert(sMessage);}sayhelloworld();会输出helloworld。在一个函数中定义另外一个函数会使闭包更复杂。var iBaseNum=10;function addNumbers(iNum1,iNum2){ function doAddition( 阅读全文
javascript 事件处理
2012-08-27 23:59 by youxin, 463 阅读, 收藏,
摘要:
W3C calls the target of the event target, while Microsoft calls it srcElement。w3c把时间的目标对象称为target,而微软称之为srcElement。事件分为3类。Mouse events, caused by a certain mouse action.Keyboard events, caused by a certain key action.Interface events, 接口事件which fire when something happens to the page, for instance, 阅读全文
Javascript DOM 编程艺术:ENHANCING CONTENT
2012-08-27 02:41 by youxin, 791 阅读, 收藏,
摘要:
作者首先提出问题:对于标签(markup)中的属性(attribute)来说,不同浏览器往往有不同的处理方法。比如 <img alt="..." title="..."/>,有些浏览器把 alt 属性当做 tooltip,但有些则把 titile 当做 tooltip。总的来说就是,当一个标签中有 attr 时,你就得听不同浏览器的摆布,它说怎么干就怎么干。为了从它手中夺回这个权利,我们可以使用一些 JS 代码来进行处理。 作者举出了第一个实例,为一篇 web 页面动态创建缩略语(abbreviation)的列表。大家知道,我们可以使用 &l 阅读全文
js prototype
2012-08-25 16:34 by youxin, 755 阅读, 收藏,
摘要:
(个人注:这篇转载的文章有许多错误,其中最重要的一条就是认为prototype构成了原型链,这是错误的。原型链与prototype没有任何关系。prototype仅仅是提供了对象的共享机制。真正与原型链有关的是__Proto__属性。)ECMAScript可以识别两种类型的对象,一种叫做Native Object属于语言范畴;一种叫做Host Object,由运行环境提供例如document对象,Dom Node等Native objects是一种松散的结构并且可以动态的增加属性(property),所有的属性都有一个名字和一个值,这个值可以是另一个对象的引用或者是内建的数据类型(String 阅读全文
浙公网安备 33010602011771号