+ 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 Answers
+ 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