简体   繁体   中英

JSF - graphicImage - replace broken image

I am wondering, is there a way to replace broken image with some other one in JSF when using grapicImage?

I found a solution in JavaScript:

<img src="image.png" onError="this.onerror=null;this.src='/images/noimage.gif';" />

However graphicImage doesn't support onError handling.

It possible using a simple jQuery script:

<script type="text/javascript">
      jQuery(document).ready(function() {
      var $ = jQuery;
      var Element = ".poster";
      $(Element).error(function () {
          $(this).unbind("error").attr("src", "error.jpeg");
      });
      });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM