判断路径是不是图片。str.substring(str.length-3)
== 'jpg'    

解决方案 »

  1.   

    判断 是否图片类型可以用 正则 。  jpg gif png tmp 也就那么几种图片格式 判断图片是否存在
    document.getElementById("brandLogo").style.backgroundImage ="url("+ escape(PosterName) +")";
    if(!IsExist(escape(PosterName)))
    {
    document.getElementById("brandLogo").style.backgroundImage ="url(images/channelposter/MCLogo.JPG)";
    }
      

  2.   

    正则 表达式  \w+\.jpg|\w+\.gif|\w+\.png|\w+\.tmp|\w+\.JPG|\w+\.GIF|\w+\.PNG|\w+\.TMP