0

我在<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>

您的帮助将不胜感激。提前致谢!

4

1 回答 1

0

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

控制台面板中还列出了 JavaScript 语法错误。确保选中显示 JavaScript 错误选项以查看它们。

此外,Firebug wiki 中提供了有关脚本调试的详细说明。

塞巴斯蒂安

于 2013-10-17T07:33:02.830 回答