- JScript code
<?php header("Content-Type: text/html; charset=gb2312"); ?> <script language="javascript"> function check(){ document.form1.submit(); } </script> <script language="javascript"> function re() { var http = new ActiveXObject("Microsoft.XMLHTTP"); http.open("GET","message.php",false); http.send(); var str = http.responsebody; t.innerHTML=str; setTimeout( "re()" , 2000 ); } </script> <script language="JavaScript" type="text/javascript"> window.setInterval("run()",100); function run() { with(window.document.body) { setAttribute("scrollTop",40000); } } </script> <body onLoad="re();"> <span id=t>Loading...</span> </body>
最早这个代码还有一个bytes2BSTR函数,但是这个函数是vbs写的,里面有个chr函数似乎IE7 IE8都不支持了,原本在IE6是可以用的.
问了别人,别人说现在不需要用bytes2BSTR,通过header("Content-Type: text/html; charset=gb2312");
直接设定好编码就可以了,所以我就删除了哪个函数 直接t.innerHTML=str; 这样赋值,结果报错类型不匹配,请问要怎么修改才能让这段代码运行正常呢?
------解决方案--------------------
message.php 这个文件本身的编码改为UTF-8的,(用系统的记事本打开文件,文件菜单-另存为-编码选UTF-8)
------解决方案--------------------
推荐直接使用JQuery。他已经兼容了不同的平台。EXTJS也行。