随笔分类 -  JavaScript

预防clickjacking的一个小技巧
摘要:WHATWG的HTML5文档开发者版本中举例提到了预防clickjacking的一个小技巧,即通过判断点击的页面是属于主窗口还是iframe框架中的子窗口,达到防止攻击者给用户呈现一个虚假的主窗口来引诱用户点击从而进一步获取信息。以jsfiddle.net为例,我们挑选供javascript输入的iframe框与主窗口之间进行对比:首先,在iframe中输入console.log(top);console.log(self);console.log(top==self);运行后结果是Window jsfiddle.netWindow /_display/false而将同样的代码输入到主窗口下的 阅读全文

posted @ 2012-04-01 12:51 JulianHere 阅读(310) 评论(0) 推荐(0)

【转】使用jquery实现图片预加载提高页面加载速度和用户体验
摘要:我们在做网站的时候经常会遇到这样的问题:一个页面有大量的图片导致页面加载速度缓慢,经常会出现一个白页用户体验很不好。那么如何解决这个问题呢?首 先我们会想到的是提高服务器性能,使用静态缓存等手段来加快图片的加载速度,这的确是个好方法,不过有时候我们也可以从前台找一些解决的 方法。下面我来介绍一种在实际应用中经常会使用到的js预加载的方法。 首先在输出图片的时候我们做一些处理<img data="这里是我们要显示图片的实际地址" src="这里是一张默认显示的小图片,可以快速加载到页面。可以是所有图片使用统一的图片也可以是要显示图片的缩略图" alt 阅读全文

posted @ 2012-03-23 09:06 JulianHere 阅读(1081) 评论(0) 推荐(0)

Graceful Degradation and Progressive Enhancement
摘要:一篇对优雅降级和渐进提升解释得比较好的文章。http://accessites.org/site/2007/02/graceful-degradation-progressive-enhancement/ 阅读全文

posted @ 2012-03-11 10:16 JulianHere 阅读(150) 评论(0) 推荐(0)

闭包的一种理解,赞!
摘要:我们都知道JavaScript中闭包的概念实在是晦涩难懂,有时或许知道某种形式是闭包,可就不晓得怎么样向另一个人解释闭包。今天偶尔在 http://www.css88.com/archives/4492 这个页面上发现了一段对闭包的很形象的描述:“这次,我用的是闭包的方式去实现,其中最重要的一点是reutrn Return; 这里会引伸到值类型与引用类型的概念。在js里,Object就是一个引用类型,在闭包里,我会抛出一个包含有属性与方法的Object的引用,这样,也 可以说是把这个Object抛向了外部,实现了公开。StaticClass这个变量接住了Return引用。 对于闭包内部的私有字 阅读全文

posted @ 2012-03-10 23:49 JulianHere 阅读(180) 评论(0) 推荐(0)

jQuery中的冒泡机制的一个注意点
摘要:jQuery中可用于事件代理的函数有 .live(), .delegate(), .on()等,其中.live()在jQuery早期版本中就存在了,但是由于其存在的诸多问题(具体可查看官方文档),现已不推荐使用。总的来说,delegate()和on()差不多是等效的,只不过on()是1.7版本新添加的,官方可能以后会优先发展on()的扩展功能。 而在delegate()官方文档页面有一段话:Since the .live() method handles events once they have propagated to the top of the document, it is ... 阅读全文

posted @ 2012-03-01 15:49 JulianHere 阅读(255) 评论(0) 推荐(0)

【转】Event Delegation Made Easy
摘要:From http://danwebb.net/2008/2/8/event-delegation-made-easy-in-jqueryI’m having a lot of fun poking around jQuery at the moment and came up with a cool little thing that’s going into Low Pro for jQuery but is a nice stand-alone little snippet for implementing event delegation. Since the Christian an 阅读全文

posted @ 2012-03-01 10:01 JulianHere 阅读(136) 评论(0) 推荐(0)

【转】JavaScript Event Delegation is Easier than You Think
摘要:转自 http://www.sitepoint.com/javascript-event-delegation-is-easier-than-you-think/By Andrew Tetlaw | July 23, 2008 | JavaScript & CSSIf you’re into adding a little JavaScript interactivity to your web pages you may have heard of JavaScript event delegation and thought it was one of those convolut 阅读全文

posted @ 2012-02-24 14:21 JulianHere 阅读(192) 评论(0) 推荐(0)

【转】JavaScript的那些书
摘要:转自 http://limu.iteye.com/blog/1267475 又好久没写东西了,写上一篇的时候还以为接下来的工作会轻松一些,结果未从我所愿呐,又是一阵忙碌.而这段时间穿插着做了很多12年淘宝校园招聘的前端面试,很多同学都有问到,学校里没有前端的课程,那如何学习JavaScript? 我的回答是:读书吧~相对于在网上学习,在项目中学习和跟着有经验的同事学习,书中有着相对完整的知识体系,每读一本好书都会带来一次全面的提高.而如果深一脚浅一脚的学习,写出代码的质量会参差不齐.初学者的首要任务是成为靠谱的熟练开发者,能够稳定的输出有一定质量的代码,这样才能让人放心的把任务交给你.从这个角 阅读全文

posted @ 2012-02-22 11:12 JulianHere 阅读(162) 评论(0) 推荐(0)

【转】Chrome: Cranking Up The Clock
摘要:转自 http://www.belshe.com/2010/06/04/chrome-cranking-up-the-clock/Chrome: Cranking Up The ClockJun 4th, 2010 at 12:32 amOver the past couple of years, several of us have dedicated a lot of time to Chrome’s timer system. Because we do things a little differently, this has raised some eyebrows. 阅读全文

posted @ 2012-02-10 18:03 JulianHere 阅读(303) 评论(0) 推荐(0)

【转】jquery $.fn $.fx是什么意思
摘要:转自 http://hi.baidu.com/ejejqq/blog/item/ad18256bf30e24c180cb4adc.html$.fn是指jquery的命名空间,加上fn上的方法及属性,会对jquery实例每一个有效。如扩展$.fn.abc()那么你可以这样子:$("#div").abc();通常使用extend方法扩展,详细请看API.$.fx是指jquery的特效。如果使用显示、滑动、淡入淡出、动画等。$.fx.off可以关闭动画,其实是直接显示结果。jquery的extend和fn.extendjQuery为开发插件提拱了两个方法,分别是:jQuery.f 阅读全文

posted @ 2012-01-04 23:00 JulianHere 阅读(446) 评论(0) 推荐(0)

【转】JQuery -- this 和 $(this) 的区别
摘要:转自 http://www.cnblogs.com/RuiLei/archive/2009/08/20/1550804.html起初以为this和$(this)就是一模子刻出来。但是我在阅读时,和coding时发现,总不是一回事。What is "this"?In many object-oriented programming languages, this (or self) is a keyword which can be used in instance methods to refer to the object on which the currently e 阅读全文

posted @ 2012-01-01 16:40 JulianHere 阅读(200) 评论(0) 推荐(0)

【转】jQuery之父John Resig对JavaScript单线程工作原理的阐释
摘要:原文链接:http://ejohn.org/blog/how-javascript-timers-work/How JavaScript Timers WorkBy John ResigAt a fundamental level it's important to understand how JavaScript timers work. Often times they behave unintuitively because of the single thread which they are in. Let's start by examining the thre 阅读全文

posted @ 2011-12-13 14:45 JulianHere 阅读(275) 评论(0) 推荐(0)

在jQuery中获取浏览器窗口的尺寸信息
摘要:在jQuery中获取浏览器及页面的长度与宽度主要用到以下几个代码:$(window).height() //浏览器时下窗口可视区域高度 $(document).height() //浏览器时下窗口文档的高度 $(document.body).height() //浏览器时下窗口文档body的高度 $(document.body).outerHeight(true) //浏览器时下窗口文档body的总高度 包括border padding margin $(window).width() //浏览器时下窗口可视区域宽度 $(do... 阅读全文

posted @ 2011-12-09 22:26 JulianHere 阅读(1367) 评论(0) 推荐(1)