我倒
<span id=s1><input type="text" name="b" value="fadsfd"></span>
<span id=s2><input type="text" name="a" value="bbbb"></span>
<input type="button" onclick="document.all.s1.innerHTML=document.all.s2.innerHTML;document.all.a[0].focus()">
a[0]是什么东西啊
页面上没有这个东西嘛
当然不行了

解决方案 »

  1.   

    <span id=s1><input type="text" name="b" value="fadsfd"></span>
    <span id=s2><input type="text" name="a" value="bbbb"></span>
    <input type="button" onclick="document.all.s1.innerHTML=document.all.s2.innerHTML;setTimeout('document.all.a[0].focus()',100);">
    好像是执行速度的问题,我设了一个100毫秒的延时,就好了,你试试
      

  2.   

    因为两个span相互copy以后,变成这样的:
    <span id=s1><input type="text" name="a" value="bbbb"></span>
    <span id=s2><input type="text" name="a" value="bbbb"></span>控件重名了,两个name="a"了,应该显示脚本错误
      

  3.   

    document.all.s1.innerHTML
    复制需要时间的
      

  4.   

    try:<input type="button" onclick="document.all.s1.innerHTML=document.all.s2.innerHTML;document.getElementsByName('a')[1].focus();document.getElementsByName('a')[0].focus();">
      

  5.   

    这样就好了
    <span id=s1><input type="text" name="b" value="fadsfd"></span>
    <span id=s2><input type="text" name="a" value="bbbb"></span>
    <input type="button" onclick="aaa()">
    <script>
    function aaa(){
    document.all.s1.innerHTML=document.all.s2.innerHTML;
    document.all.a(0).select();
    document.all.a(0).focus();
    }
    </script>
      

  6.   

    回复人: tianch(晴空) ( ) 信誉:100  2004-11-11 14:29:00  得分: 0  
     
     
       看看我给的代码,延时100毫秒再执行就ok了,对于使用者来说,看不出来延时
      
     
    ================================================================================
    问题是:要延时多少呀,这只是个简单的例子,实际情况比这复杂
      

  7.   

    回复人: tianch(晴空) ( ) 信誉:100  2004-11-11 14:42:00  得分: 0  
     
     
       延时时间你可以根据实际情况来调整啊
      
     
    ======================================================================
    在不同的机器上,执行速度不一样,会不会有影响呢
      

  8.   

    javascript完全由客户端来执行,所以不存在网速的问题,关键是客户端机器配置,我想复制一点文本对于现在的机器来说耗费的时间应该用耗秒来记算,看看你复制的文本长度有多少吧,100个字符1毫秒的时间应该是够了的
      

  9.   

    想到一个好办法,这样应该能达到你的要求了
    <script language="JavaScript">
    var timer;
    </script>
    <span id=s1><input type="text" name="b" value="fadsfd"></span>
    <span id=s2><input type="text" name="a" value="bbbb" onFocus="clearInterval(timer);"></span>
    <input type="button" onclick="document.all.s1.innerHTML=document.all.s2.innerHTML;timer=setInterval('document.all.a[0].focus()',1)">
      

  10.   

    请教一下.那个innerHTML是什么属性?
    还有setInterval函数我用过来显示时间的,可是不能时时变阿?