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