Jquery 判断DOM对象是否存在

On 2009年07月28日, in Javascript, by Kane

最近在研究 greenmonkey ,发现 userscripts.org 里面提供了很多网站的一些 script。

回归正题,jquery 如何判断DOM 是否存在..

if($("#test").length>0)  或者  if($("#test").size()>0)

 

 

Tagged with:  

非静态化页面的iframe 自适应高度

On 2009年07月17日, in Javascript, by Kane

传统的iframe 自适应高度

<iframe id="frame_content" src="frame_content.html" scrolling="no" frameborder="0" onload="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>

这种是针对 frame内容已静态输出了高度。而当frame页面有 dom 操作改变了页面高度的时候,怎么办?

参考了 口碑UED 的一片文章,使用的方法是setInterval 不断刷新frame框架页面,让frame内容页面高度改变时调整高度。 而为了避免影响性能,可以通过 iframe内的页面对dom操作改变了高度的时候,再去执行父级调整iframe高度。

最后代码:

<iframe id="frame_content" src="iframe_content.html" scrolling="no" frameborder="0" onload="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>

<script type="text/javascript">

function reinitIframe(){

var iframe = document.getElementById("frame_content");

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight;

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

var height = Math.max(bHeight, dHeight);

iframe.height =  height;

}catch (ex){}

}

// window.setInterval("reinitIframe()", 200);

</script>

<!--在iframe_contnet.html 页面,当对DOM操作的时改变了高度,就加入下面代码。 -->
window.parent.reinitIframe();
Tagged with:  

在这里强烈屌7 x独份子,搞到我们很多网站都上不到。正扑街含家产! 为了可以正常使用社交网站的服务,提供修改hosts方法访问。那些暴动份子看了死全家!

修复 Facebook YouTube fs2you twitter 等一些常用网站。高级用户自己看吧.. 把不需要的删了。

添加下面到 system32/drivers/etc/host 文件

124.40.42.105 www.facebook.com
124.94.101.133 cachefile13.fs2you.com
124.94.101.133 file13.fs2you.com
124.94.101.146 cachefile25.fs2you.com
124.94.101.146 file25.fs2you.com
125.46.41.27 cachefile18.fs2you.com
125.46.41.27 file18.fs2you.com
125.91.11.223 cachefile19.fs2you.com
125.91.11.223 file19.fs2you.com
127.0.0.1 activate.adobe.com
128.121.146.101 assets0.twitter.com
128.121.146.101 assets1.twitter.com
128.121.146.101 static.twitter.com
128.121.146.228 twitter.com
128.121.146.228 www.twitter.com
128.121.146.229 assets2.twitter.com
128.121.146.229 assets3.twitter.com
203.208.33.100 gdata.youtube.com
203.208.39.104 www.youtube.com
208.80.152.2 en.wikipedia.org
208.80.152.2 wikipedia.org
208.80.152.2 www.wikipedia.org
208.80.152.2 zh.wikipedia.org
209.85.225.136 mt2.google.com
218.75.151.10 cachefile15.fs2you.com
218.75.151.10 file15.fs2you.com
218.75.151.4 cachefile11.fs2you.com
218.75.151.4 file11.fs2you.com
221.204.246.115 cachefile14.fs2you.com
221.204.246.115 file14.fs2you.com
221.204.246.79 cachefile3.fs2you.com
221.204.246.79 file3.fs2you.com
222.169.230.101 dyn.www.fs2you.com
222.169.230.98 cachefile2.fs2you.com
222.169.230.98 file2.fs2you.com
281.201.39.38 klinoneshoes.info
58.211.75.31 cachefile12.fs2you.com
58.211.75.31 file12.fs2you.com
58.211.75.49 cachefile8.fs2you.com
58.211.75.49 file8.fs2you.com
58.218.209.126 cachefile16.fs2you.com
58.218.209.126 file16.fs2you.com
58.218.209.49 cachefile.fs2you.com
58.218.209.49 file.fs2you.com
59.32.232.195 cachefile1.fs2you.com
59.32.232.195 file1.fs2you.com
59.53.48.134 cachefile20.fs2you.com
59.53.48.134 file20.fs2you.com
59.53.48.136 cachefile21.fs2you.com
59.53.48.136 file21.fs2you.com
59.53.48.144 cachefile22.fs2you.com
59.53.48.144 file22.fs2you.com
59.53.48.172 cachefile24.fs2you.com
59.53.48.172 file24.fs2you.com
60.2.139.27 cachefile5.fs2you.com
60.2.139.27 file5.fs2you.com
61.134.84.238 cachefile9.fs2you.com
61.134.84.238 file9.fs2you.com
61.139.106.204 cachefile23.fs2you.com
61.139.106.204 file23.fs2you.com
61.150.85.80 cachefile4.fs2you.com
61.150.85.80 file4.fs2you.com
61.156.40.181 cachefile10.fs2you.com
61.156.40.181 file10.fs2you.com
61.157.152.173 cachefile17.fs2you.com
61.157.152.173 file17.fs2you.com
61.166.111.227 cachefile26.fs2you.com
61.166.111.227 file26.fs2you.com
61.174.62.131 cachefile7.fs2you.com
61.174.62.132 file7.fs2you.com
61.184.189.10 cachefile6.fs2you.com
61.184.189.10 file6.fs2you.com
64.211.21.152 b.static.ak.facebook.com203.208.39.104 youtube.com
64.233.161.104 help.youtube.com
64.233.161.104 maps.l.google.com
64.233.161.136 mt1.google.com
64.233.161.147 map.google.com
64.233.161.147 www.google.com
64.233.161.190 mt0.google.com
64.233.161.93 mt.l.google.com
64.233.169.17 googlemail.l.google.com
65.74.185.41 help.twitter.com
65.74.185.41 twitter.zendesk.com
66.102.1.103 www.l.google.com
66.102.1.83 mail.google.com
69.192.34.110 s-static.ak.facebook.com
69.63.176.59 secure-media-sf2p.facebook.com
69.63.176.69 secure-profile.facebook.com
69.63.178.13 ssl.facebook.com
69.63.180.173 login.facebook.com
72.14.247.111 pop.gmail.com
74.125.113.101 docs.google.com
74.125.113.101 spreadsheets.google.com
74.125.113.147 scholar.google.com
74.125.45.100 google.com
74.125.91.113 groups.l.google.com
74.125.91.118 upload.youtube.com
74.125.91.136 picasaweb.google.com
74.125.93.101 books.google.com
74.125.93.102 groups.google.com
74.125.93.102 id.google.com
74.125.93.102 id.l.google.com
74.125.93.102 insight.youtube.com
74.125.93.111 smtp.gmail.com
74.125.93.136 khm.google.com
74.125.93.99 news.google.com
96.6.122.57 profile.ak.facebook.com
rayfile.com fs2you.com
www.rayfile.com www.fs2you.com

 

HTML5 帮助文档 cheet sheet (PDF)

On 2009年07月7日, in HTML5&CSS3, by Kane

HTML5 帮助文档 PDF 版

 

XHTML2 的死亡,意味着HTML5将会成为主流。现在开始学习吧。

 

下载地址: 点击下载此文件

 

XHTML 2 Working Group Expected to Stop Work End of 2009, W3C to Increase Resources on HTML 5

2009-07-02: Today the Director announces that when the XHTML 2 Working Group charter expires as scheduled at the end of 2009, the charter will not be renewed. By doing so, and by increasing resources in the Working Group, W3C hopes to accelerate the progress of HTML 5 and clarify W3C’s position regarding the future of HTML. A FAQ answers questions about the future of deliverables of the XHTML 2 Working Group, and the status of various discussions related to HTML. Learn more about the HTML Activity.

 

13个firebug增强插件

On 2009年07月1日, in Collection, by Kane

Firebug 是每个前端和开发必备的插件,这里就不多说了。这里介绍一下13个插件,另你的firebug更强大。

 

 

YSlow(Why slow?-为什么慢呢?)

YSlow是一款用来分析网页,并提出前端性能改进建议的Firefox插件。YSlow依据预定义或用户自定义的规则为网页评级。它同时提供了许多性能分析工具,如:Smush.it™JSLint

 

 

 

Page Speed

与YSlow非常相似,Page Speed是google团队推出的一款用于评测网页性能的插件,尤其可以依据“网页性能最佳实践”对网页性能提出改进建议。
Page Speed可以自动优化图片,并提供压缩版本。它也可以侦测到那些实际并未用到的Javascript和css,以便优化它们。
Page Speed可是个1.3M的大插件,它还拥有许多优秀功能等你尝试。

 

 

 

Pixel Perfect

在制作网页时,在页面上添加一个新的设计元素(例如一个图片或图标)之前,我们往往希望提前看到元素添加后页面的整体效果。Pixel Perfect就可以帮你实现这个想法,它允许开发者在网页上覆盖你要添加的设计元素。使用它时你可以调整要添加元素的透明度和位置。
我感觉这款插件也可用来做网页中元素的微调,以保证和最初设计蓝图一致,如它的名字,完美到一个像素都不差。

 

 

 

CodeBurnder

安装CodeBurner后,可以再firebug面板中看到参考面板用来查询html元素、html属性、css属性,就像一个字典一样。
当在Firebug中选中一个节点时,它也会提供一些相关的代码示例供你参考。

 

 

 

FireUnit

FireUnit提供了一个简单的API用来做简单的测试记录及单元测试。

 

 

 

FirePHP

在FirePHP的帮助下,你可以通过调用一个简单的PHP方法,在Firebug中记录日志。

数据是通过响应包头(Response Header)发送的,不会影响到网页内容。

 

 

 

FireRainbow

FireRainbow 可以用来控制、修改Firebug中Script的语法高亮显示。

 

 

 

FireDiff

It adds a change monitor recording every change made, by Firebug and the website itself, to CSS and the DOM.
它能够记录通过Firebug或网站自身的CSS或DOM的每一次改动。

这个我装上后,也没看出firebug上多了什么,也不知该怎么用。希望知道的朋友留言说一声。

 

 

 

Jiffy Firefox Extension

安装Jiffy Firefox Extension后会在Firebug中出现一个新面板,用来图形化显示Javascript的运行时间,并可打印出报表。

看主页说明,使用好像还有点麻烦。感兴趣的朋友自己看下。

 

 

 

Hammerhead

Hammerhead可以帮助你计算网页的载入时间。(这个好像Firefox本身具备啊)

它支持多页面,并允许你清除磁盘或内存缓存后再进行载入时间测试。

 

 

 

Firecookie

Firecookie, 是一个嵌入在Firebug中的cookie浏览管理插件。

如果在Web开发中用到了cookie,使用它可以轻松的浏览cookie值、过期时间等,有助于快速开发。

使用它时需要在Firebug的网络面板中开启cookie监测。它可同时显示发送和接收的cookies。

 

 

 

Firefinder

通过CSS 或者 Xpath 来查找 elements。

 

 

 

LiveCoder

LiveCoder是Firebug的一个扩展,用来查看Firefox Chrome。这对与那些Firefox插件开发者非常有用,它可以帮你检查、修改Firefox插件的Dom。

 

 

让浏览器自动刷新XRefresh

On 2009年07月1日, in Collection, by Kane

每个前端或者开发人员,当页面有改动的时候都需要去刷新浏览器来查看页面的改动。

XRefresh  当项目文件夹有更新的时候,会为你自动刷新浏览器。

 

他包含2部分,一个是作为浏览器的插件形式( Firefox & IE) firefox的话是基于firebug的,另一个是桌面程序 ( Windows & Mac)。

一个显示器显示起来可能不够明显,如果条件好,有2台显示,一个是IDE 一个是浏览器的话那么是很爽的。