【发布时间】:2018-10-04 05:22:03
【问题描述】:
如果链接断开或不存在,下面的 sn-p 会将 PNG 图像替换为 GIF 图像。我试图在 iframe 上应用它,但它似乎不起作用。这甚至可能吗?
<html>
<body>
<iframe src="index1.html" onerror="this.onerror=null;this.src='https://media.giphy.com/media/3oEjI6SIIHBdRxXI40/giphy.gif';"> </iframe>
<img src="test.png" onerror="this.onerror=null;this.src='https://media.giphy.com/media/3oEjI6SIIHBdRxXI40/giphy.gif';" />
</body>
</html>
非常感谢您的回复。提前致谢! :)
【问题讨论】:
-
可以单独使用JS查看链接是否存在 display id_a else display id_b
-
嗨 Muhammed,我有一个想法,javascript 可以做到这一点,但我不确定如何执行它
标签: javascript html css onerror