根据需要我用js代码输出这样的内容:
document.write('<a id="index" href="javascript:CLOSELF(\'Index.aspx\')">首  页</a> | &nbsp;');然后使用js获取这个标记
var current=document.getElementById("index");IE中执行正常。火狐里就不行。用FireBug调试,发现current的值为null是不是火狐获取不到用js输出的html元素呢?怎么解决呢?

解决方案 »

  1.   

    没firefox,chrome试了一下,还是可以的
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script language="javascript">
            document.write('<input type=text id=txt>');
        </script>
    </head>
    <body>
        <input id="Button1" type="button" value="button" onclick="alert(document.getElementById('txt').value)" />
    </body>
    </html>
      

  2.   

    我用ff试过是可以的,你的FF是什么版本?
      

  3.   

    非常感谢楼上两位。火狐2.0.0.20我用FireBug加断点调试,获取不到
      

  4.   

    手上没有2.0 

    document.createElement来试试.
      

  5.   

    估计是你的创建方法不规范
    建议过document.createElement