Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Html and asp.net mvc

Posted on 2016-09-18
3
Medium Priority
?
82 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
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)

604 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