为什么Firebug无法检测到某些JavaScript?

时间:2013-10-17 05:36:04

标签: javascript firebug

我在<body>结束标记之外编写了JavaScript。 Firebug无法检测到JavaScript,我无法检测到JavaScript错误。

这是我的代码:

</body>
<script type="text/javascript">

function displayIFrameContent()
{   
    var iFrame = document.getElementById("link");
    var if1= "<iframe src='http://leadmarket.hol.es/forms/solar-power.php?adv_id=" + <?php echo($fetch_users_data['id']); ?>; 
    var if2= "<iframe src='http://leadmarket.hol.es/forms/kitchen-installation.php?adv_id=" + <?php echo($fetch_users_data['id']); ?>; 
    var if3= "<iframe src='http://leadmarket.hol.es/forms/conservatory.php?adv_id=" + <?php echo($fetch_users_data['id']);; ?>; 

    var host = document.getElementById("host");
    var subId = document.getElementById("subid");
    var errorClass = "box form-validation-error border-width-2";

    if(host.value == "")
        changeClass("host", errorClass);

    if(host.value != "")
    {       
        var iFrameEnd = " width='280' height='330' frameborder='0' scrolling='no'></iframe>";

        var leadTypeSelect = document.getElementById("leadType");
        var leadTypeValue = leadTypeSelect.options[leadTypeSelect.selectedIndex].value;

        iFrame.value  = "";

        if(leadTypeValue == 1)
            iFrame.value  = if1 + "&" + "sub_id=" + subId.value + "&source=" + host.value + "'" + iFrameEnd;

        if(leadTypeValue == 2)
            iFrame.value  = if2 + "&" + "sub_id=" + subId.value + "&source=" + host.value + "'" + iFrameEnd;

        if(leadTypeValue == 3)
            iFrame.value  = if3 + "&" + "sub_id=" + subId.value + "&source=" + host.value + "'" + iFrameEnd;
    }       
}


function changeClass(id, classname) 
{
    document.getElementById(id).setAttribute("class", classname);
}   
</script>
</html>

我们将不胜感激。提前谢谢!

1 个答案:

答案 0 :(得分:0)

上面的代码包含PHP标记,这会导致一些语法错误。在这种情况下,“脚本”面板仅显示消息“此页面上没有Javascript”。您应确保在将它们输出到浏览器之前由PHP解释它们。

Console Panel中还列出了JavaScript语法错误。确保选中显示JavaScript错误选项以查看它们。

此外,Firebug wiki中还提供了详细的description about script debugging

塞巴斯蒂安