Q:http://www.csdn.net/expert/Topicview1.asp?id=857893我用如下代码,生成新窗口。var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>");
doc.writeln("<body>中文内容</body></html>");但中文都变成了?   为什么?
操作系统为英文win2k  ie6   系统可以正常显示中文网页
A: 不知道算不算已经解决了
<script>
function trans(str){
var reg=/[^\x00-\xff]/g
var idx=0,ret="";
while(reg.exec(str)){
ret+=str.substring(idx,RegExp.lastIndex-1)+"&#"+RegExp.lastMatch.charCodeAt(0)+";"
idx=RegExp.lastIndex;
}
ret+=str.substring(idx)
return(ret);
}var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln(trans("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>"));
doc.writeln(trans("<body>中文内容</body></html>"));
</script>

解决方案 »

  1.   

    css2文档:
    http://www.blueidea.com/user/qswh/css2.chmwsh文档: 
    http://www.blueidea.com/user/qswh/wsh.chmjs文档: 
    http://www.blueidea.com/user/win1st/other/jsdoc.exe
      

  2.   

    Q: 为什么有“Automation服务器不能创建对象”A: 安全问题限制将网站加入可信任站点,然后启用 
    Internet选项->安全->可信任站点->自定义级别->对没有标志为安全的ActiveX进行初始化和脚本运行
      

  3.   

    Q:如何让后退时网页自动刷新A:设置本地无缓存
    http://www.blueidea.com/bbs/newsdetail.asp?id=346635HTTP:
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    或者<META HTTP-EQUIV="expires" CONTENT="0">
    ASP
    response.expires=0
    response.addHeader("pragma","no-cache") 
    response.addHeader("Cache-Control","no-cache, must-revalidate")PHP
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
      

  4.   

    http://www.csdn.net/expert/topic/834/834057.xml?temp=.5421564
      

  5.   

    Q: http://www.csdn.net/expert/Topicview1.asp?id=858947
    请问JavaScript中有没有可以精确到某一位的四舍五入的方法?
    例如MyRound(n,m),意为:将数字n精确至小数点后m位<script>
    function MyRound(n,m){
    //IE5.5以下
    with(Math)return round(n*pow(10,m))/pow(10,m)
    }
    function MyRound6(n,m){
    //IE5.5以上
    return n.toFixed(m);
    }
    alert(MyRound(1.245,2));
    alert(MyRound6(1.245,2));
    </script>
      

  6.   

    qiushuiwuhen (秋水无恨) .偶像
      

  7.   

    Q: http://www.csdn.net/expert/Topicview1.asp?id=861801
    var XH = new ActiveXObject ("Microsoft.XMLHTTP");
    XH.Open("get", "link_select_get.php?depart="+val, false);
    XH.Send("");
    alert(XH.responseText);A: bytes2bstr(XH.responseBody)<script language=vbs>
    function bytes2bstr(vin)
    dim i,strreturn
        strreturn = ""
        for i = 1 to lenb(vin)
            thischarcode = ascb(midb(vin,i,1))
            if thischarcode < &h80 then
                strreturn = strreturn & chr(thischarcode)
            else
                nextcharcode = ascb(midb(vin,i+1,1))
                strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
                i = i + 1
            end if
        next
        bytes2bstr = strreturn
    end function
    </script><script language=jscript>
    var XH = new ActiveXObject ("Microsoft.XMLHTTP");
    XH.Open("get", "link_select_get.php?depart="+val, false);
    XH.Send("");
    alert(bytes2bstr(XH.responseBody));
    </script>
      

  8.   

    Q: http://www.csdn.net/expert/Topicview1.asp?id=860340
    在html中有一个input的数组,需要知道当前正在输入的input控件在此数组中的下标A: 利用它和parentElement的sourceIndex差别
    <script>function show(e){window.status=e.sourceIndex-e.parentElement.sourceIndex}</script>
      

  9.   

    Q: http://www.csdn.net/expert/Topicview1.asp?id=853339
    var a=12;
    var b=0.2作如下运算:
    parseFloat(a)*parseFloat(b)
    得出的是2.4000000000000003如何才能只得到2.4?A: 
    <script>
    function qswhMul(p1,p2){
    /********(qiushuiwuhen 2002-07-05)************/
    var e1=0,e2=0,s1=String(p1),s2=String(p2);
    try{e1=s1.split(".")[1].length}catch(e){}
    try{e2=s2.split(".")[1].length}catch(e){}
    r=Number(s1.replace(".",""))*Number(s2.replace(".",""))
    return r/Math.pow(10,e1+e2)
    }
    alert(qswhMul(12,0.2));
    alert(qswhMul(1.8,0.2));
    </script>
      

  10.   

    http://www.csdn.net/expert/Topicview1.asp?id=870034
    我能用javascript来合计一个表格的一列或一行并显示在最后一列或最后一行吗?遍历即可
    <table id=demo border=1>
    <tr><td>1</td><td>2</td></tr>
    <tr><td>3</td><td>4</td></tr>
    <tr><td>5</td><td>6</td></tr>
    </table>
    <script>
    y=demo.rows.length;
    x=demo.rows[0].cells.length;
    if(confirm("行还是列?")){
    for(i=0;i<y;i++){
    sum=0;for(j=0;j<x;j++)sum+=Number(demo.rows[i].cells[j].innerText);
    demo.rows[i].insertCell().innerText="该行和"+sum
    }
    }else{
    row=demo.insertRow()
    for(j=0;j<x;j++){
    sum=0;for(i=0;i<y;i++)sum+=Number(demo.rows[i].cells[j].innerText);
    row.insertCell().innerText="该列和"+sum
    }
    }
    </script>
      

  11.   

    Q: 什么代码能检测Array对象和Object对象
     
    A:
    hasOwnProperty 要求 版本 5.5,
    instanceof  要求 版本 5
    constructor 要求 版本 2<script>
    function chkArr(o){return typeof(o.length)!="undefined"}
    function isArr(o){return o.constructor==Array}var arr=[1,2,3,4]
    var obj={1:2,3:4}
    alert(chkArr(arr))
    alert(chkArr(obj))
    alert(isArr(arr))
    alert(isArr(obj))
    </script>
      

  12.   

    Q:如何处理F5刷新和onbeforeunload的矛盾A:判断鼠标位置或是否有alt+F4function window.onbeforeunload(){
    with(event)if(clientX>document.body.clientWidth &&clientY<0||altKey)
    return "Are u sure?"
    }
      

  13.   

    收藏!以QA的方式非常好,继续关注,有机会整理一下!
    thanks秋水!~
      

  14.   

    flylyke(爱就像英雄莫问出处) :
    秋水是姐姐吗?如果是大家都去追她了,hehe。此帖不收藏简直就是浪费
      

  15.   

    qiushuiwuhen(秋水无恨),原来还是MM,佩服~~~~~~
      

  16.   

    http://www.csdn.net/expert/Topicview1.asp?id=924567使用非贪婪匹配
    <script>
    str="[apple]hehe[/apple]xixi[apple]hehe[/apple]"
    alert("贪婪匹配的结果:"+str.replace(/\[apple\](.+)\[\/apple\]/g,"<a>$1</a>"))
    alert("非贪婪匹配的结果:"+str.replace(/\[apple\](.+?)\[\/apple\]/g,"<a>$1</a>"))
    </script>
      

  17.   

    如果还不行,可以用
    <script>
    str="bananaxixiapple"
    str=str.replace(/\[url\](.+?)\[\/url\]/g,function($0,$1){return ($1).indexOf("apple")==-1?"<a>"+$1+"</a>":""+$1+""})alert("结果:"+str)
    </script>
      

  18.   

    It's great!!!!!!!!!!!!!!!!!!!!!!!!!!111
      

  19.   

    在HTML页面中,元素有一个属性 tabIndex,即按tab键时,跳到元素的顺序。
    我怎么知道 tabIndex等于某个值的元素是什么?
    我怎么将焦点focus到指定tabIndex等于某个值得元素上??
      

  20.   

    遍历元素集合(有tabIndex属性的子集)进行查找不就行了..
      

  21.   

    在一个函数中,怎么知道现在获得焦点的元素是哪个? 
    1.onfocus
    <input name=input1 onfocus=window.status=name>
    <input name=input2 onfocus=window.status=name>
    <input name=input3 onfocus=window.status=name>
    <input name=input4 onfocus=window.status=name>2.activeElement
    <input name=input1>
    <input name=input2>
    <input name=input3>
    <input name=input4>
    <script>
    function getAct(){window.status=document.activeElement.name}
    setInterval(getAct,100)
    </script>
      

  22.   

    要在脚本中判断当前页面是否有焦点可不能这样子..我写了个HTC.给能接受焦点的element定义了一个行为,扩充其属性.
    如下:<PUBLIC:PROPERTY NAME="isFocus" GET="_getFocus"/>
    <PUBLIC:ATTACH EVENT="onfocus" ONEVENT="_focus()" />
    <PUBLIC:ATTACH EVENT="onblur" ONEVENT="_blur()" />
    <SCRIPT LANGUAGE="JScript">
    var isFocus=false;
    function _getFocus()
    {
       return isFocus;
    }
    function _focus()
    {
    isFocus=true;
    }
    function _blur()
    {
    isFocus=false;
    }
    </SCRIPT>存为a.htc
    如下使用:<HTML>
    <HEAD>
    <TITLE></TITLE>
    </HEAD>
    <BODY onbeforeunload="alert(xxx.isFocus||xxx.isFocus);return false" ondblclick="alert(xxx.isFocus||xxx.isFocus)">
    <P>
    <button id=xxx style="behavior:url(a.htc)" onclick="alert(xxx.isFocus)">open</button>&nbsp;
    <button id=yyy style="behavior:url(a.htc)" onclick="alert(yyy.isFocus)">leave</button>&nbsp;
    </BODY>
    </HTML>
      

  23.   

    要知道全部元素中是否有获得焦点的,就通过扩充的isFocus判断.
      

  24.   

    十分感谢各位回答我的问题,但还有几个没有解决:
    1、我如何知道指定tabIndex的是哪个元素
    2、我怎么知道tabIndex最大是多少?
    3、当我用如下脚本:
    if(window.event.keyCode == 13){
        window.event.keyCode=9;
    }
    将ENTER键实现TAB键的功能后,当焦点在最后一个元素时,
    如果再按下ENTER键,焦点从页面上消失了,
    焦点这时候在那里?如何让焦点再回到页面上
      

  25.   

    为什么我在服务器上创建adodb.stream对象失败本地却好用呢,秋水兄
      

  26.   

    to tracter(无事可作):
    一般用sourceIndex,每个控件都有,系统自带
    tabIndex是用来手动调节tab顺序的,人工设置所以我不建议通过tabIndex,
    <input><input><input><input><input>
    <script>
    function document.onkeydown(){
    with(window.event){
    if((keyCode==13)&&(document.all(srcElement.sourceIndex+1).tagName=="INPUT"))keyCode=9;
    window.status="soruceIndex:"+srcElement.sourceIndex+" tabIndex:"+srcElement.tabIndex
    }
    }
    </script>
      

  27.   

    to tdl982324(石井坚)
    1.Adodb.Stream需要IIS5才自带
    2.可能你没有权限或被管理员禁止了
      

  28.   

    to qiushuiwuhen(秋水无恨)怎么设置权限呢