?
Solved

Html and asp.net mvc

Posted on 2016-09-18
3
Medium Priority
?
76 Views
Last Modified: 2016-09-18
HI Guys,

I'm showing picture in my html page in this way:

<img src="smiley.gif" alt="There is no picture" width="42" height="42">

Open in new window


The issue I have is when the picture doesn't exist I would like to alt="There is no picture" message.
I'm getting the message but I'm getting also little thumb nail which I don't need.

There is work around it to make just the message to appear in case picture doesn't exist?


Thanks,
0
Comment
Question by:Moti Mashiah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 total points
ID: 41804021
There's no handy css or js property you can hook into do validate that, but there is a js event.
The images if they don't download properly will throw an "error" event (onerror),
You would have to hook up an event handler for that to change the class or hide the image if and when that is thrown.
0
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 41804057
Now the question is how do I do it.

Can you send some code example?

Thanks,
0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 41804066
Thank you for the idea.

Here is how I solved it.

var img = document.getElementById("myImg");
img.onerror = function () {
    this.style.display = "none";
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question