网络编程
位置:首页>> 网络编程>> JavaScript>> prototype.js1.4版开发者手册(8)

prototype.js1.4版开发者手册(8)

作者:THIN 来源:cnblogs 发布时间:2007-09-30 14:09:00 

标签:prototype,手册


对String的扩展


MethodKindArgumentsDescription
stripTags()instancee(none)
stripScripts()
(none)返回一个把所有的script都移除的字符串。
escapeHTML()instance(none)返回一个把所有的HTML标记合适的转义掉的字符串。
unescapeHTML()instance(none)escapeHTML()的反转。
extractScripts()instance(none)返回一个包含在string中找到的所有<script>的数组。
evalScripts()instance(none)执行在string中找到的所有<script>。
toQueryParams()instance(none)把querystring分割才一个用parameter name做index的联合Array,更像一个hash。
parseQuery()instancee(none)和toQueryParams()一样..
toArray()instance(none)把字符串转换成字符数组.
camelize()instance(none)转换一个以连字符连接的字符串成一个骆驼法样式的字符串。比如,这个函数在写代码时,把它做为一个样式工具使用是很有用的。



对  Array的扩展

因为array扩展于enumerable,所以所有enumberable对象的函数,array都是可以使用的,除此之外,下面的这些也是已经实现了的。


MethodKindArgumentsDescription
clear()
(none)清空。
compact()instance(none)返回一个不包括源array中null或undefined元素的array,此方法不改变源array。
first()instance(none)返回array的第一个对象。
flatten()instance(none)通过递归组合array每个元素的子元素(如果该元素也是array)来返回一个“扁平的”一维的array。
indexOf(value)instancevalue: what you are looking for.返回给出数字位置(从0算起)的元素,如果在该位置没有找到对象,返回-1。
inspect()instance(none)重载inspect(),返回更好格式的反映Array每个元素的字符描述。
last()instance(none)返回最后一个元素。
reverse([applyToSelf])instanceapplyToSelf: indicates if the array itself should also be reversed. 反转Array中元素的顺序,如果没有给出参数,或参数为true,则源Array中元素的顺序也反转,否则源Array保持不变。
shift()instance(none)返回Array的第一个元素并从Array中移除它,Array的Length-1。
without(value1 [, value2 [, .. valueN]])instancevalue1 ... valueN: values to be excluded if present in the array. 返回一个把参数列表中包含的元素从源Array中排除的Array。



document DOM扩展


MethodKindArgumentsDescription
getElementsByClassName(className [, parentElement])
className: name of a CSS class associated with the elements, parentElement: object or id of the element that contains the elements being retrieved.返回所有CSS className属性等于className参数的元素,如果没有给出parentElement,那么将搜索document body。(此处使用document.body我觉得不如使用document,因为有时有的页面没有body) 



Event扩展


PropertyTypeDescription
KEY_BACKSPACENumber8: Constant. Code for the Backspace key.
KEY_TABNumber9: Constant. Code for the Tab key.
KEY_RETURNNumber13: Constant. Code for the Return key.
KEY_ESCNumber27: Constant. Code for the Esc key.
KEY_LEFTNumber37: Constant. Code for the Left arrow key.
KEY_UPNumber38: Constant. Code for the Up arrow key.
KEY_RIGHTNumber39: Constant. Code for the Right arrow key.
KEY_DOWNNumber40: Constant. Code for the Down arrow key.
KEY_DELETENumber46: Constant. Code for the Delete key.
observers:ArrayList of cached observers. Part of the internal implementation details of the object.



MethodKindArgumentsDescription
element(event)staticevent: an Event object返回事件源对象。
isLeftClick(event)staticevent: an Event object如果点击了鼠标左键,返回true.
pointerX(event)staticevent: an Event object返回鼠标的X座标。
pointerY(event)staticevent: an Event object返回鼠标的Y座标。
stop(event)staticevent: an Event object使用此函数来中断事件的默认行为并阻止传递(冒泡)。
findElement(event, tagName)staticevent: an Event object, tagName: name of the desired tag.从事件源对象开始向上搜索DOM树,直到找到第一个符合tagName的元素
observe(element, name, observer, useCapture)staticelement: object or id, name: event name (like ’click’, ’load’, etc), observer: function to handle the event, useCapture: if true, handles the event in the capture phase and if false in the bubbling phase.为对象的某个事件增加一个处理函数。
stopObserving(element, name, observer, useCapture)staticelement: object or id, name: event name (like ’click’), observer: function that is handling the event, useCapture: if true handles the event in the capture phase and if false in the bubbling phase.和上面的函数相反。
_observeAndCache(element, name, observer, useCapture)static 私有函数,别管它。
unloadCache()
(none)私有函数,别管它。从内存中清除所有的observers缓存。


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com