脚本加载.理论上可能是为了减少重复代码. 不过现在好象被不少站点用于隐藏某些内容.
就象用 flash player 播放 flv 一样. 并不只是为了发挥该文件格式的优越性.该页面中的游戏为:
<embed width="100%" height="100%" bgcolor="#000000"
src="http://www.my33.com/lashfile/2005/game/1/10/20051129225544.swf">
就象用 flash player 播放 flv 一样. 并不只是为了发挥该文件格式的优越性.该页面中的游戏为:
<embed width="100%" height="100%" bgcolor="#000000"
src="http://www.my33.com/lashfile/2005/game/1/10/20051129225544.swf">
javascript:alert(document.documentElement.outerHTML);javascript:document.write(document.documentElement.outerHTML);是看当前页代码..javascript:alert(iframes[n].document.documentElement.outerHTML);javascript:document.write(iframes[n].document.documentElement.outerHTML);就可以看到IFRAME里的内容了...javacript:alert(iframes.length);查看有多少个IFRAME
:D
这个callback的执行文件(脚本回调)
不用ajax比较好(除非要求有同步请求,但是这个回调很显然是不需要的)EMU提供了若干种兼容方法,不过FF更新2点xx版本后,就不好用了...
@,@先贴EMU的方法...
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var isIE = !!window.ActiveXObject;
var useFragment=false;
function loadjs(url,callback,errcallback){
if(isIE){
if(useFragment){
var df = document.createDocumentFragment();
df.visitCountCallBack = function(data){
s.onreadystatechange=null;
df=null;
callback(data);
}
var s = df.createElement("SCRIPT");
df.appendChild(s);
s.onreadystatechange=function(){
if(s.readyState=="loaded") {
s.onreadystatechange=null;
df=null;
errcallback();
}
}
s.src = url;
}else{
var i=new ActiveXObject("htmlfile");
i.open();
i.parentWindow.visitCountCallBack=function(i){
return function(d){
i.parentWindow.errcallback=null;
i=null;
callback(d);
}
}(i);
i.parentWindow.errcallback=function(d){
i.parentWindow.errcallback=null;
i=null;
errcallback(d);
}
i.write("<script src=\""+url+"\"><\/script><script defer>setTimeout(\"errcallback()\",0)<\/script>")
if(i)i.close();//如果数据被cache,运行到这一行的时候有可能回调已经完成,窗口已经关闭。
}
}else{
var i = document.createElement("IFRAME");
i.style.display="none";
i.callback=function(o){
callback(o);
i.contentWindow.callback=null;
i.src="about:blank"
i.parentNode.removeChild(i);
i = null;
};
i.errcallback = errcallback;
i.src="javascript:\"<script>function visitCountCallBack(data){frameElement.callback(data)};<\/script><script src='"+url+"'><\/script><script>setTimeout('frameElement.errcallback()',0)<\/script>\"";
document.body.appendChild(i);
}
}function init(){
var spans = document.getElementsByTagName("span");
for(var i=0;i<spans.length;i++){
var id = spans[i].id;
var url = "http://g2.qzone.qq.com/fcg-bin/cgi_emotion_list.fcg?uin="+id;
var callback = function(id){ return function(data){
document.getElementById(id).innerHTML = data.visitcount;
}
}(id);
var errcallback = function(id){ return function(){
document.getElementById(id).innerHTML = "无法连接到服务器";
}
}(id);
loadjs(url,callback,errcallback);
}
}
</SCRIPT>
</HEAD>
<BODY onload="init()">
123456 的访问量:<span id="123456"></span><BR>
2543061 的访问量:<span id="2543061"></span><BR>
20050606 的访问量:<span id="20050606"></span><BR>
</BODY>
</HTML>
<script type="text/javascript">
var callbackJS = function (name, url, callback, errorcallback) {
if (/MSIE/.test(window.navigator.userAgent)) {
var frag = document.createDocumentFragment(), script = frag.createElement('script');
frag[name] = function () {
frag = script = script.onreadystatechange = frag[name] = null;
callback.apply(null, arguments);
};
script.onreadystatechange = function () {
if (script.readyState == 'loaded') { script.onreadystatechange = null, errorcallback(); }
};
script.src = url;
frag.appendChild(script);
} else {
//虽然解决了,不过有点不爽,毕竟操作当前页很不爽
window.setTimeout(function () {
var tempCallBack = window[name], div = document.createElement('div');
window[name] = function () {
window[name] = tempCallBack, div.parentNode.removeChild(div), tempCallBack = window.__errorcallback = div = null;
callback.apply(null, arguments);
};
window.__errorcallback = errorcallback;
div.innerHTML = '<script type="text\/javascript" src="' + url + '"><\/script>'
+ '<script type="text\/javascript">window.setTimeout("try{__errorcallback();}catch(e){}", 0);<\/script>';
document.body.appendChild(div);
if (window.opera) {
div.innerHTML = div.innerHTML;
document.body.removeChild(div);
document.body.appendChild(div);
}
}, 0);
}
};
window.onload = function () {
callbackJS(
'_Callback', 'http://b.qzone.qq.com/cgi-bin/blognew/blog_get_data?uin=185591441&numperpage=15&blogid=1200979684&arch=0&pos=0&direct=1&r=0.9963684245893007'
, function () {
alert(arguments[0].data.title);
}
, function () {
alert(0);
}
);
};
</script>
←李宇春什么时候做了程序员?
不过JS写得非常不错!