<div id = '147'>
<u><b><font color = 'blue' onClick = 'javascript:showbox(147)'>Comment </font</b></u>
</div>
<script type='text/javascript'>
<!--
function showbox(var1) {
document.getElementById(var1).innerHTML = var1 + " <form name = 'commentform' method = 'post' action = ''><input type='text' name = 'comment' value='Enter Your Comment' ><input type='hidden' value= " + var1 + " name='wallpostid'> <input type ='hidden' value = '$userid' name = 'userid' > <input type='submit' name = 'send' value='Post your Comment' onClick='javascript:postcomment()'> </form>";
<b onclick= 'postcomment()' > </b>;
}
function postcomment() {
document.commentform.comment.submit();
}
-->
</script>
上面是代码。它在 FF 中工作,但在 IE 或 Chrome 中不工作。
谁能告诉我哪里出错了。有什么解决方案可以让它在所有浏览器中运行吗?
最佳答案
这里有一些错别字:
"...<input type='hidden' value= " + var1 + " name='wallpostid'>... "
"...<input type='hidden' value='" + var1 + "' name='wallpostid'/>... "
注意 /
和两个 '
还有这一行
<b onclick= 'postcomment()' > </b>;
不执行任何操作,因为它是在 javascript 中而不是文件的 html 部分。
关于javascript 浏览器问题在 FF 中有效,但在 IE 和 Chrome 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7138283/