document.getElementById('src').focus();
document.execCommand("selectall");
document.execCommand("Delete");
document.GetElementById('onlinesrc').Focus();//这句无效
谁知道什么原因啊!src为一input type=file标签   onlinesrc为text 标签名册或者哪个知道当text文档获得焦点时将file里内容清空的其它办法啊?

解决方案 »

  1.   

    注意大小写document.getElementById('onlinesrc').focus();
      

  2.   


        var file1 = document.getElementById('src').value;
        if (file1!="") { //防止死循环
            document.getElementById('src').focus(); 
            document.execCommand("selectall"); 
            document.execCommand("Delete");
            setTimeout("document.getElementById('onlinesrc').focus();",10); //延时即可
        }
      

  3.   

    能不能告诉我原因!按这种办法是可行的!是不是execCommand的问题啊?
      

  4.   

    document.getElementById('onlinesrc').focus();