+ 5

How to skip alt= attribute situation⁉️ HTML <img src= ... alt= ... /> [FIXED]

My code displays random SoloLearn Avatars. But when the generated avatar address is incorrect & the avatar cannot be loaded, the alt= attribute is activated. In this case, I would like to jump to generating a new, correct address and displaying the next avatar. In 🐍 I solved this problem by using: try: except: How to avoid this situation in web code⁉️🤔 I'm not an expert in "The Holy Trinity", HTML+CSS+JS‼️😕 https://code.sololearn.com/WXEmMRkrNa89/?ref=app https://code.sololearn.com/caW7TeDOLM6W/?ref=app

21st Feb 2022, 10:45 AM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
7 Réponses
+ 4
Add onerror="next()" to the image tag
21st Feb 2022, 3:32 PM
ODLNT
ODLNT - avatar
+ 6
ODLNT You are Genius‼️ onerror='next()' works‼️ Thx a lot‼️☺️
21st Feb 2022, 8:15 PM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
+ 3
ODLNT Does "download" attribute of hyperlink work in SoloLearn? I tried to wrap the image in a hyperlink with "download" attribute but it opens up the browser instead of allowing the file to be saved ... https://code.sololearn.com/W0856YcmseVM/?ref=app
21st Feb 2022, 4:35 PM
Ipang
+ 3
Ipang According to MDN the download attribute on sololearn app is working as it should, it appears the user must download from a browser instead of the webview. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
21st Feb 2022, 6:30 PM
ODLNT
ODLNT - avatar
+ 3
Genius?! ...I'll take it😁. I'm glad I could help.
21st Feb 2022, 10:20 PM
ODLNT
ODLNT - avatar
+ 2
Thank you ODLNT 🙏
21st Feb 2022, 6:35 PM
Ipang
- 5
K ckx xkzklo oo lh,ox see lll
22nd Feb 2022, 8:56 PM
Luna Michelle Velasquez Bocanegra