但是腾讯的这个页面改过版了,我是今天才发现的。用以前的代码已经不能点击打开聊天窗口了,生成的新代码比以前长了,多了个sigkey,64位的(好长 )。
以我的QQ为例子,在那个页面生成的代码如下:
实现代码如下:

<a href="http://sighttp.qq.com/cgi-bin/check?sigkey=cfad9f0a103b59616e94d667dd5755e92c2be98ded5ad949a940399e013adfe2"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=cfad9f0a103b59616e94d667dd5755e92c2be98ded5ad949a940399e013adfe2';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://wpa.qq.com/pa?p=1:56536321:2' alt="56536321"></a>

是不是很长?而且就这样放进网页,那么页面肯定过不了W3C认证,SRC是大写,再如“;target=_blank; ”。如果要放好几个QQ,那页面岂不是也很乱。怎么办?
我对比了两个QQ,发现只有那个64位的sigkey不一样,所以可以把onclick移出来,代码: 
实现代码如下:

<script type="text/javascript">
function QQtalk(sigkey) {
var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey='+sigkey;
var oldscript=document.getElementById('testJs');
var newscript=document.createElement('script');
newscript.setAttribute('type','text/javascript');
newscript.setAttribute('id', 'testJs');
newscript.setAttribute('src',tempSrc);
if(oldscript == null) {
document.body.appendChild(newscript);
}
else {
oldscript.parentNode.replaceChild(newscript, oldscript);
}
return false;
}
</script>

然后直接onclick="return QQtalk('cfad9f0a103b59616e94d667dd5755e92c2be98ded5ad949a940399e013adfe2');"

网页body内的代码可以写成: <a href="http://sighttp.qq.com/cgi-bin/check?sigkey=cfad9f0a103b59616e94d667dd5755e92c2be98ded5ad949a940399e013adfe2" target="_blank" onclick="return QQtalk('cfad9f0a103b59616e94d667dd5755e92c2be98ded5ad949a940399e013adfe2');"><img src="http://wpa.qq.com/pa?p=1:56536321:3" alt="56536321"></a>

以上就是【QQ在线状态代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论