dqve65954 2016-07-11 05:38
浏览 203

Javascript onerror事件无效

i'm making an admin portal where admin can create users,and when they create user they only add their basic details. so when a user logs in to the system he finds a broken image. to fix that i did some digging and found out about onerror event in img tag. I tried using it,but it is not working.

my code : <img src="images/<?php echo $image;?>" onError="this.onerror=null;this.src='/images/abc.png';"/>

Please help me out here,this is the only task remaining to finish of my 1st project.

  • 写回答

1条回答 默认 最新

  • donglu6303 2016-07-11 05:46
    关注

    As mentioned, you can use PHP to check if the image exists and replace it server-side. To answer your question about the image onerror function, see: jQuery/JavaScript to replace broken images

    评论

报告相同问题?

悬赏问题

  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)