<script>
var online= new Array();
</script>
<!--检测是否在线-->
<script src="http://webpresence.qq.com/getonline?Type=1&178806071:"></script>
<script>
<!--如果在线,则显示以下内容-->
if (online[0]==0)
document.write("<a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=178806071&Site=qqjia.com&Menu=no' title='当前离线或隐身'>QQ:178806071</a><font color=#636563>当前离线或隐身</font>");
else
<!--如果离线,则显示以下内容-->
document.write("<a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=178806071&Site=qqjia.com&Menu=no' title='当前在线'>QQ:178806071</a><font color=red><b>当前在线</b></font>");
</script>
如上代码直接放到网页里能正常显示,我把她转换为以下代码保存为a.js后用<script language="javascript" src="a.js"></script> 调用,就出现一个问题,无论qq是否在线显示的都是在线的状态,问题出在哪里呢
document.writeln("<script>");
document.writeln("var online= new Array();");
document.writeln("</script\>");
document.writeln("<!--检测是否在线-->");
document.writeln("<script src=\"http://webpresence.qq.com/getonline?Type=1&178806071:\"></script\>");
document.writeln("<script>");
document.writeln("<!--如果在线,则显示以下内容-->");
document.writeln("if (online[0]==0)");
document.writeln("document.write(\"<a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=178806071&Site=qqjia.com&Menu=no' title='当前离线或隐身'>QQ:178806071</a><font color=#636563>当前离线或隐身</font>\");");
document.writeln("else");
document.writeln("<!--如果离线,则显示以下内容-->");
document.writeln("document.write(\"<a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=178806071&Site=qqjia.com&Menu=no' title='当前在线'>QQ:178806071</a><font color=red><b>当前在线</b></font>\");");
document.writeln("</script\>");
document.writeln("");