我用document.form1.textareaname.value取Iframe中textarea的值 
第一次总是取不到,但第二次又取的到。 
这怎么回事,应该怎么弄?

解决方案 »

  1.   

    <textarea id="content" name="content" style="display:none"></textarea>
    <IFRAME ID="eWebEditor1" src="/eWebEditor/eWebEditor.jsp?id=content&style=standard&ofilename=images_with_orgname&savefilename=images_without_path&savepathfilename=images_with_path&savedPhysicalPath=<=savedPhysicalPath>&webPath=<%=webPath%>"frameborder="0" scrolling="no" width="650" height="350"></IFRAME>
    这是jsp代码
    在一个button的onclick事件中调用下面js代码
    <script>
    var a = document.form1.content.value;
    alert(a);
    </script>第一次去取不到值,刷新页面后第二次又取的到。
      

  2.   

    可以用
    <script> 
    var a =document.getElementById("content").value;
    alert(a); 
    </script> 
      

  3.   

            var a= eWebEditor1.getHTML();   //eWebEditor1是Iframe的ID,getHTML()是内置方法。
            for(var i = 0; i < a.length; i++){
                a= a.replace("<p>","");    //去掉空格和换行
                a= a.replace("</p>","");
                a= a.replace("<P>","");
                a= a.replace("</P>","");
                a= a.replace("&nbsp;","");
            }
            a=a.replace(/^\s+|\s+$/g,"");
            if(a==""){
                alert("<%=getString("content");
            }应该是这样
    我解决了,楼上的也不行,有漏洞,第一次取不到。