google adsense 不允许页面中同时出现 yahoo 的广告(竞争对手呗),但可以交替显示。这个代码的有趣之处在于,解决了 adsense 不允许任何改动的问题。
所有的 ” 用 ” 代替
换行用
\n
/script 用 /script 代替
This is an example of how to paste your ad javascripts correctly into the googlead and yahooad variables (do not use these as is, otherwise you will end up sending me money ):
var googlead = “\n
\n
\n
”
var yahooad = “\n
\n
\n
”
via A javascript wrapper to rotate Google-Adsense and YPN ContentMatch ads.
貌似这个 中国第八军团安全竞赛网络版 只有四关?有点旧,但还有点意思,一般的右键之类肯定是关掉的。思路如下:
第一关:就是个 unescape,直接在 firefox ctrl+A 选择全部,右键查看 view selection source 就能看到密码;
第二关:unescape 里面还有个
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
这个 Get the rendered style of an element 是2006年4月的24发的,但我今天才看到。
为了拿到元素的当前样式
ie 用 currentStyle 和 runtimeStyle
ff 用 getComputedStyle
opera 似乎是直接 style 和 getComputedStyle 都可以(记不清楚了,谅解)
以前都是自己写,再说公司的破项目仍然都在 ie 6 下跑,因此倒还没感到痛苦。
函数定义
function getStyle(oElm, strCssRule){
var strValue = “”;
if(document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(oElm, “”).getPropertyValue(strCssRule);
}
else if(oElm.currentStyle){
strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
strValue = oElm.currentStyle[strCssRule];
}
return strValue;
}
调用
getStyle(document.getElementById(”container”), “font-size”);
唯一缺点在于 ie 5,需要加 try catch
下载 getStyle.js
以前的方法有 SWFObject 和 UFO,flashReplace 的作者 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.replace("flash-content", "/flash/my-movie.swf", "flash-element-id", 800, 200);
FlashReplace.replace("da-cool-header", "/flash/cool-header.swf", "flash-element-id", 600, 350, 7, {wmode : "transparent"});
FlashReplace.replace("sidebar", "/flash/sidebar.swf", "flash-element-id", 200, 700, 7,
{
wmode : "transparent",
quality: "high",
bgcolor: "#ffffff"
}
);