没有样式就是最好的样式

javascript 交替显示 google 和 yahoo 广告

Jan 8, 2008 Author: | Filed under: Uncategorized

google adsense 不允许页面中同时出现 yahoo 的广告(竞争对手呗),但可以交替显示。这个代码的有趣之处在于,解决了 adsense 不允许任何改动的问题。

所有的 ” 用 ” 代替

换行用
\n
/script 用 /script 代替

显示更多

via A javascript wrapper to rotate Google-Adsense and YPN ContentMatch ads.

网页解密练习

Jan 1, 2008 Author: | Filed under: Uncategorized

貌似这个 中国第八军团安全竞赛网络版 只有四关?有点旧,但还有点意思,一般的右键之类肯定是关掉的。思路如下:

第一关:就是个 unescape,直接在 firefox ctrl+A 选择全部,右键查看 view selection source 就能看到密码;

第二关:unescape 里面还有个

这里是链接测试

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

得到页面元素当前样式

Dec 27, 2007 Author: | Filed under: Uncategorized

这个 Get the rendered style of an element 是2006年4月的24发的,但我今天才看到。

为了拿到元素的当前样式

ie 用 currentStyle 和 runtimeStyle

ff 用 getComputedStyle

opera 似乎是直接 style 和 getComputedStyle 都可以(记不清楚了,谅解)

以前都是自己写,再说公司的破项目仍然都在 ie 6 下跑,因此倒还没感到痛苦。

函数定义

显示更多

调用

显示更多

唯一缺点在于 ie 5,需要加 try catch

下载 getStyle.js

FlashReplace - 网页插入 flash 的解决方案

Dec 27, 2007 Author: | Filed under: Uncategorized

以前的方法有 SWFObjectUFOflashReplace 的作者 Robert Nyman 对它们展开了如下的批判:

* I didn’t find the code that easy to read, and tweak, if wanted.

flashReplace的代码易读易改

* The file size. SWFObject is about 6.7 KB and UFO is about 10.7 KB. I’m a sucker for small file sizes, so therefore FlashReplace is only 2.1 KB. :-)

swfobject 6.7K,而 UFO 要 10.7 K,flashReplace 只有 2.1K

* Neither of them created standards-compliant code; FlashReplace does. Not anymore. Now it creates an additional embed element for maximum compatibility

以上二者生成的都不是标准代码,flashReplace 加上了 embed(郭爽注:加上embed 同意,standards-compliant code 不同意,网页验证不会去读 js 产生的 html)

* Several lines are needed to insert a Flash Movie. FlashReplace only needs one line.

FlashReplace 只需要一行代码。

郭爽注:在这之前我只用过 swfobject 感觉很方便。

代码示例,猜都能猜出来,因此不做解释。

显示更多

下载 flashReplace js 代码