jQuery 1.4 发布 (updated 1.4.1)

作者:airwin 发布时间:January 15, 2010 分类:前端

在jQuery的4岁生日之时,jQuery开发团队很高兴地发布最新的jQuery1.4版本!其他的代码演示、测试、文档的更新也会陆续进行更新发 布。对于jQuery发烧友来说,jQuery1.4的发布也是一个大新闻!下面是来自于jQuery的官方网站翻译(英语高手请勿拍砖!): 在jQuery的4岁生日之时,jQuery开发团队很高兴地发布最新的jQuery1.4版本!其他的代码演示、测试、文档的更新也会陆续进行更新发布。



此外,谷歌已经提供了jQuery1.4副本,jquery团队上传到了Google服务器托管服务中。这jQuery1.4的版本是自动minified和gzip 的,地址为:
http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js




下面请看jQuery1.4在DOM上与1.3.2版本和其他框架的比较吧, 性能提升还是很大的~


jQuery1.4.1 - TaskSpeed

jQuery TOOLS - The missing UI library for the Web

作者:airwin 发布时间:October 28, 2009 分类:前端

jQuery Tools is a collection of the most important user-interface components for today's websites. This single JavaScript file weighs only 5.72 Kb

该UI库包含的都是web开发展示中最常用的功能,比官方的JUI体积小多了, 效率也高一些.

官方网站是:jQuery TOOLS
官方Demo:jQuery TOOLS Demos

推荐一系列文章:Jquery Tools——不可错过的Jquery UI库

IE下img囧人的onload问题

作者:airwin 发布时间:September 29, 2009 分类:前端

1
2
3
4
5
6
7
8
9
<ul class="tab"><li>Tab_1</li><li>Tab_2</li></ul>
<div id="div_1">
<img id="1_1" src="xx" onload="resize(this)" />
<img id="1_2" src="xx" onload="resize(this)" />
</div>
<div id="div_2" style="display:none">
<img id="2_1" src="xx" onload="resize(this)" />
<img id="2_2" src="xx" onload="resize(this)" />
</div>

简要代码如上,效果是滑动门,目的是两个div里面的图片都利用js进行按比例缩放
在resize函数里面记录, 发现在div_2(也就是display属性为none) 容器里面的img, 触发onload事件时, 本身的width 和 height 属性都是0
网上google良久, 有说window.setTimeout的, 然后我使用了如下函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function resize(image, iwidth, iheight)
{
console.debug(image.id + ' ' + image.width + ' ' + image.height);
var width = image.width;
var height = image.height;
var newwidth = 0,newheight = 0;
if(width > 0 && height > 0)
{
if (width / height >= iwidth / iheight)
{
if (width > iwidth)
{
newwidth = iwidth;
newheight = (height * iwidth) / width;
}
else
{
newwidth = width;
newheight = height;
}
if (newheight > iheight)
{
newwidth = newwidth * iheight / newheight;
newheight = iheight;
}
}
else
{
if (height > iheight)
{
newheight = iheight;
newwidth = (width * iheight) / height;
}
else
{
newwidth = width;
newheight = height;
}
if (newwidth > iwidth)
{
newheight = newheight * iwidth / newwidth;
newwidth = iwidth;
}
}
}
else {
window.console.log('retry ' + image.id);
window.setTimeout(function(){resizeImg(image,iwidth,iheight);}, 1000);
}
if(newwidth > 0 && newheight > 0)
{
image.width = newwidth;
image.height = newheight;
}
}

结果就是无限循环调用, image的width和height属性都是0.

调试: 只要 div_2 不是隐藏的, IE都能够正确取得width和height属性

问题是页面默认显示div_1, 隐藏div_2, 要在页面加载时就把图片的缩放做好..愁死我咯...

update: 临下班前搞定此问题..效果不错..

障眼法:

1
2
3
4
5
6
7
jQuery(function(){
if($.browser.msie) {
$('#div_2').show();
$('#div_2').find('img').each(function(i, img){ resizeImg(img,80,80); });
$('#div_2').hide();
}
});

搞定 ^_^

Javascript等比例缩放图片,鼠标滚轮调整大小

作者:airwin 发布时间:September 24, 2009 分类:前端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//图片按比例缩放,可输入参数设定初始大小
function resizeimg(ImgD,iwidth,iheight) {
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
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;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
     ImgD.style.cursor= "pointer"; //改变鼠标指针
     ImgD.onclick = function() { window.open(this.src);} //点击打开大图片
     if (navigator.userAgent.toLowerCase().indexOf("ie") > -1){
//判断浏览器,如果是IE
       ImgD.title = "请使用鼠标滚轮缩放图片,点击图片可在新窗口打开";
       ImgD.onmousewheel = function img_zoom() //滚轮缩放
      {
          var zoom = parseInt(this.style.zoom, 10) || 100;
          zoom += event.wheelDelta / 12;
          if (zoom> 0) this.style.zoom = zoom + "%";
          return false;
      }
    } else { //如果不是IE
        ImgD.title = "点击图片可在新窗口打开";
       }
}
}

关于IE6的一些备忘

作者:airwin 发布时间:September 24, 2009 分类:前端

最近在某个alexa统计报告中看来国内IE6还是占据了90%以上的市场, OMG.. 看来离死尚早..
做一些笔记, 以备急用...

1、不支持position:fixed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*让position:fixed在IE6下可用! */
.fixed-top /* 头部固定 */{position:fixed;bottom:auto;top:0px;}
.fixed-bottom /* 底部固定 */{position:fixed;bottom:0px;top:auto;}
.fixed-left /* 左侧固定 */{position:fixed;right:auto;left:0px;}
.fixed-right /* 右侧固定 */{position:fixed;right:0px;left:auto;}
/* 上面的是除了IE6的主流浏览器通用的方法 */
* html,* html body /* 修正IE6振动bug */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top /* IE6 头部固定 */{position:absolute;bottom:auto;top:expression
(eval(document.documentElement.scrollTop));}
* html .fixed-right /* IE6 右侧固定 */ {position:absolute;right:auto;left:expression
(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)
-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));}
* html .fixed-bottom /* IE6 底部固定 */{position:absolute;bottom:auto;top:expression
(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-
(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
* html .fixed-left /* IE6 左侧固定 */{position:absolute;right:auto;left:expression
(eval(document.documentElement.scrollLeft));}

"无振动完美模拟fixed"

Firebug 1.3.3 For Firefox 3.5

作者:airwin 发布时间:September 9, 2009 分类:前端

转帖自: http://heeroluo.net/ShowPost19.aspx

Firebug是很常用的网页前端开发工具,但是从1.4版本开始,其性能有所下降。用Firefox3.5+Firebug1.4打开网易新闻频道的首页,整个浏览器就卡死了。

由于Firebug 1.3不支持Firefox 3.5,为此,我一直还在用Firefox 3.0。后来又听说只要强制Firefox 3.5不进行兼容性检查,Firebug 1.3还是可用的。这证明Firebug在Firefox 3.5下是可以正常工作的,只是由于某些版本信息使其不支持Firefox 3.5,而插件的安装包必定存有这些信息。

阅读剩余部分...

CSS 3.0 参考手册 (中文版)

作者:airwin 发布时间:August 25, 2009 分类:前端

腾讯的同学做的,这里做个分流~

原帖见 http://webteam.tencent.com/css3/

建议和我一样一直在用苏沈小雨版css2.0手册的同学可以更新一下了~

我的VPS在美国,这里分个流~

http://www.shinewoo.cn/download/css3.0manual.chm.zip

  1. 1