激烈的辩论Javascript Chops URL

时间:2009-05-21 14:24:27

标签: php javascript

激烈辩论使用以下javascript代码在我的博客上显示评论编号,我已将其包含在一个方便的小PHP功能中。通过将此php函数传递给博客文章的ID,它会创建指向该特定帖子的评论部分的链接。

function show_comments_number($id) {
$url="index.php?p=post&id=$id";
?>
<script>
var idcomments_acct = 'xxx';
var idcomments_post_id = '<? echo $id;?>';
var idcomments_post_url = '<? echo $url;?>';
</script>
<script type="text/javascript" src="http://www.intensedebate.com/js/genericLinkWrapperV2.js"></script>
<?}

问题在于,激烈的辩论会解析我试图传递的网址,而不是&amp;以及它之后的一切。所以Intense Debate产生的链接只是“index.php?p = post” - 显然这是一个问题。

有关为什么以这种方式砍掉网址的想法?

3 个答案:

答案 0 :(得分:0)

有可能,您网址中的&amp; ID被解释为无效的HTML实体。将<script>标记包含在评论(<!--<script></script>//-->)中应该有助于此。

答案 1 :(得分:0)

&id更改为&amp;id,您应该解决它。

答案 2 :(得分:0)

或关注the W3C's advice并更改&amp;到(确保相应地修改你的argument_separator.input和argument_separator.output。)

相关问题