【问题标题】:function is undefined函数未定义
【发布时间】:2011-08-01 14:20:42
【问题描述】:

This Link is a sample

<script type="text/javascript" language="javascript">
$.blockUI({ overlayCSS: { backgroundColor: 'orange'} , message: '<img src="icon/wait.gif" /><div style=\'font-family:Tahoma;font-size:large\'> ...???? ??? ???? ??? ????</div>' });                 

function UrlExists(url)
{
    var http = new XMLHttpRequest();
    http.open('HEAD', url, false);
    http.send();
    return http.status!=404;
}

function test()
{
    var  certification = "";
    var address;
    var  idCompany="821229021";
    var Empty = true;
    for (var  i = 0; i < 10; i++)                                 
    { 
        idCompany =idCompany + i.toString();
        idCompany=idCompany + ".png";
        address="Image/CertificationCompany/"+idCompany; 

        if (UrlExists(address))
        {
            //certification += "<img style='margin:5px;padding:5px;cursor: pointer; border: 1px solid GrayText;' width='103px' height='80px;' src='Image/CertificationCompany/" + idCompany + "' />";                               
             certification +="<a href='Image/CertificationCompany/" + idCompany + "' rel='prettyPhotoCertification[pp_gal]' title=' ?????? ????????? ???? "+document.title+"'><img style='margin:5px;padding:5px;cursor: pointer; border: 1px solid GrayText;' width='103px' height='80px;' src='Image/CertificationCompany/" + idCompany + "'  alt='????????? ??' /></a>";                      

            Empty = false;
        }

        idCompany="821229021";
        //$.unblockUI();
    }

    if(Empty ){
        certification = "updating<br /><img src='icon/Updated.png' />";
    }
    $("#contentCertification").html(certification);
}

$.unblockUI();

</script>

HTML

 <input type="button" value="click me" onclick="test();"/>

2) 在 IE 中,$.blockUI() 不起作用,似乎浏览器已挂起。

This Link is a sample

【问题讨论】:

  • 当你有 jQuery 时,为什么还要使用内联 JavaScript,onclick=
  • 这些样本的真正好处是它们都没有加载。

标签: javascript jquery jquery-ui blockui jquery-blockui


【解决方案1】:
 <script type="text/jscript" language="javascript">

应该是

 <script type="text/javascript">

【讨论】:

  • 我认为省略这些并使用简单的&lt;script&gt; 会更容易
  • 看不懂请写样例
【解决方案2】:

你是如何加载 jQuery 和插件的?确保您不使用自闭合脚本标记,在 IE 上不起作用。

<script src="js/blockui.js" />       <!-- WRONG -->
<script src="js/blockui.js></script> <!-- CORRECT -->

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-01
    • 2014-06-19
    • 1970-01-01
    • 2021-10-16
    • 2018-12-20
    • 1970-01-01
    • 2021-11-06
    • 2020-12-15
    相关资源
    最近更新 更多