今天在测试页面的时候突然发现jquery.js文件在下载过程中,后半截文件被替换成上半截文件了,也就是一个文件中下了两个头部信息。
奇怪的是其他js文件又都是好的。
最后总算找到解决方法
将httpd.conf文件中,去掉下面两行的注释:
# EnableMMAP off
# EnableSendfile off
至于为什么,应该就是这个吧
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
兼容所有浏览器
<div id="_mcePaste">var body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');</div>
<div id="_mcePaste">body.animate({scrollTop: $('#id').offset().top}, 500);</div>
其中$(‘#id’)为要跳转到的位置元素
实际参数在函数中我们可以使用 arguments 对象获得 (注:形参可通过 arguments.callee 获得),虽然 arguments 对象与数组形似,但仍不是真正意义上的数组。
值得庆幸的是,我们可以通过数组的 slice 方法将 arguments 对象转换成真正的数组:
var args = Array.prototype.slice.call(arguments, 0);
对于slice 方法,ECMAScript 262 中 15.4.4.10 Array.prototype.slice (start, end) 章节有备注:
The slice function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. Whether the slice function can be applied successfully to a host object is implementation-dependent.
《Pro JavaScript Design Patterns》(《JavaScript 设计模式》)的作者 Dustin Diaz 曾指出:
instead of…
var args = Array.prototype.slice.call(arguments, 0); // 怿飞注:下称方法一
do this…
var args = [].slice.call(arguments, 0); // 怿飞注:下称方法二
但二者的性能差异真的存在吗?经过个人简单测试发现:
在 arguments.length 较小的时候,方法二性能上稍有一点点优势,而在arguments.length 较大的时候,方法一却又稍有优势。
2010年1月30日更新(测试地址):几经验证,性能差异不大,反而第一张方法性能稍优势一点,或许由于第二种方法创建新数组产生开销。
最后附上方法三,最老土的方式:
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
不过对于平常来说,个人建议使用第一种方法,但任何解决方案,没有最好的,只有最合适:
var args = Array.prototype.slice.call(arguments, 0);
1.打开一个新窗口:window.open();为了便于父窗口操作子窗口可以为window.open()定义一个变量,例如:
var opW = window.open(‘tests.html’,’popup’,’width=300,height=300′);
这样要关闭子窗口可直接使用:opW.close();
要操作子窗口元素,例如:
opW.document.getElementById(“fartherWindowTxt”).innerHTML = “操作子窗口”;
2.子窗口可以使用window.opener来引用父窗口:window.opener.document.getElementById(“fartherWindowTxt”).innerHTML=”子窗口操作父窗口!”;
3.窗口关闭自身窗口可以使用:window.close();
看代码:
alert(parseInt(0.000001));
alert(parseInt(0.0000001));
第一条语句输出 0, 第二条语句输出 1, 囧。
继续看代码:
alert(parseInt(’0.000001′));
alert(parseInt(’0.0000001′));
都输出 0, 这才符合预期。
查看 ECMA-262 规范,parseInt 会先调用 toString 方法。问题已逐渐清晰:
alert(0.000001);
alert(0.0000001);
第一条语句原样输出,第二条语句输出 1e-7.
继续翻查 ECMA-262 9.8.1 ToString Applied to the Number Type 一节,恍然大悟:
assertEquals(“0.00001″, (0.00001).toString());
assertEquals(“0.000001″, (0.000001).toString());
assertEquals(“1e-7″, (0.0000001).toString());
assertEquals(“1.2e-7″, (0.00000012).toString());
assertEquals(“1.23e-7″, (0.000000123).toString());
assertEquals(“1e-8″, (0.00000001).toString());
assertEquals(“1.2e-8″, (0.000000012).toString());
上面是 V8 引擎 number-tostring 的单元测试脚本, 很好地诠释了 ECMA 规范。
小结:对于小于 1e-6 的数值来说,ToString 时会自动转换为科学计数法。因此 parseInt 方法,在参数类型不确定时,最好封装一层:
function parseInt2(a) {
if(typeof a === 'number') {
return Math.floor(a);
}
return parseInt(a);
}
文章收集自http://playgoogle.com/?p=316和http://playgoogle.com/?p=351这两篇
获得选中文件
<pre> var PG={
isIE:!-[1,], //判断浏览器是否为IE,为IE时返回true
getText:function(){
if(this.isIE){
return this._getText();
}else{
var element = document.activeElement;
if (element && (element.tagName.toLowerCase() == 'input' || element.tagName.toLowerCase() == 'textarea')) {
return this._getTextInput()
} else {
return this._getText()
}
}
},
_getText:function(){
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.selection && document.selection.createRange) {
return document.selection.createRange().text;
}
return "";
},
//获取非IE浏览器中input框和textarea框中的文字
_getTextInput:function(){
var element = document.activeElement;
if (element.selectionStart != undefined && element.selectionEnd != undefined) {
return element.value.substring(element.selectionStart, element.selectionEnd);
}
return "";
}
}</pre>
使用方法
<pre> document.onmouseup = function(){
alert("您选中的文字是:"+PG.getText());
}</pre>
demo
选中指定文字
<pre>var PG={
isIE:!-[1,], //判断浏览器是否为IE,为IE时返回true
/*
* 设置文本框中的文字为选中状态,包括开始索引,不包括结束索引
* param domObj 文本框的dom对象,start为开始索引,不填则从0开始, end为结束索引,不填则选中到文本结束
* 若domObj参数不填,则直接返回为false.
*/
setSelectText:function(domObj,start,end){
if(typeof domObj !=="object"){
return false;
}
start = start ||0;
end = end || domObj.value.length
domObj.focus();
if(this.isIE){
var range = domObj.createTextRange();
range.move("character",start);
range.moveEnd("character",end-start);
range.select();
}else{
domObj.setSelectionRange(start,end)
}
}
}</pre>
demo
前台开发,很多人喜欢用JQuery,但是在做后台管理系统,特别是企业管理系统,例如WEB进销存系统等,很多人都会选择ExtJS,因为ExtJS提供了非常多的UI界面,并且非常友好。
现在JQuery也有一个很好的UI插件了,几乎完全可以替代ExtJS,下面来看看对比:

jQuery EasyUI framework help you build your web page easily.
- easyui is a collection of user-interface plugin based on jQuery.
- using easyui you don’t need to write many javascript code, you usually defines user-interface by writing some HTML markup.
- easyui is very easy but powerful.
Easy UI的使用也非常地简单:
<div>
<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><script type="text/javascript" src="../jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../jquery.easyui.min.js"></script></div>
</div>
与引用其它JQuery插件类似。具体使用可以参考官方地址:http://jquery-easyui.wikidot.com/tutorial
下面是Easy ui目前提供的所有插件功能:
Menu and Button
Create a simple menu
Create a Link Button
Create a Menu Button
Create a Split Button
Layout
Build border layout for Web Pages
Complex layout on Panel
Create Accordion
Create Tabs
Create XP style left panel
DataGrid
Convert a HTML table to DataGrid
Add a pagination to DataGrid
Get selected row data from DataGrid
Add a toolbar to DataGrid
Frozen columns for DataGrid
Dynamic change DataGrid columns
Formatting DataGrid columns
Add sorting to DataGrid
Create column groups in DataGrid
CheckBox select on DataGrid
Window
My first window
Custom window tools
Window and Layout
Create Dialog
Tree
Create Tree from markup
Create Async Tree
Append nodes to tree
Form
Submit a form with Ajax
Add ComboTree field to a form
Form Validation
用过ExtJS的朋友都知道,他与JQuery来比,ExtJS是比较臃肿的一个JS框架,JQuery它是一个公认的轻量级JS框架,而基于JQuery的Easy UI它能够完全胜任我们的基本开发需求,并且比ExtJS要轻量许多。
赶快去体验吧,一定会对你的工作有很大帮助的!下载地址:http://jquery-easyui.wikidot.com/download
jQuery.Switchable是一款整合了Tabs、Slide、Scrollable等常见UI组件的jQuery插件。它有简单易用的API、可灵活配置的Configuration,支持自定义Effect,支持自主开发Plugin。
jQuery.Switchable能实现什么样的效果?看图:
Tabs

Slide

Scrollable

详细说明——演示——下载
帮胖胖把google buzz绑定到他的博客上了,之前用pirobox感觉有点bug,结果今天一看才发现,是博客风格里用的那个jquery版本低了,是1.26的,赶紧换了一个最新版的
顺便推荐一下,图片浏览样式很好
pirobox 官方地址http://www.pirolab.it/pirobox/