Ask Experts Questions for FREE Help !
Ask
    bekbutatz's Avatar
    bekbutatz Posts: 1, Reputation: 1
    New Member
     
    #1

    Apr 13, 2009, 02:15 AM
    How to put a prompt when there is no image during popup
    Hello! I have a the following code at the head
    ===
    function popUp(popurl){
    var winpops=window.open("","LargeImage","location=no,m enubar=no,status=no,directories=no,scrollbars=no,t oolbar=no,width=350,height=500");

    if (popurl != null) {winpops.document.write("<center><img src= '"+popurl+"' >"); }
    else {
    winpops.document.write("<BR><BR><BR>");

    winpops.document.write("<br><center><img src= '"+popurl+"' alt='No Image Available at this Time' >");
    }

    winpops.document.write("<BR><BR><BR>");
    winpops.document.write("<input type='button' value=' Close Window ' onclick='javascript:window.close()'>");
    }
    ===

    and at the body
    <A HREF="javascript:popUp('computer.jpg')"><img src="computer.jpg"></a></TD>

    How do I put a message that tells if that image is not available? Thanks
    jstrike's Avatar
    jstrike Posts: 418, Reputation: 44
    Full Member
     
    #2

    May 26, 2009, 02:17 PM
    This should do the trick but you'll need to fully test it...
    Code:
    <script>
    	function isImageAvailable(imgPath) {
    		var img = new Image();
    		img.src=imgPath;
    		return img.height>0;
    	}
    
    
    if(!isImageAvailable("/images/SomeImage.png")) 
    	alert("That image is not available");
    </script>
    The only problem with doing it this way is that if the image is large the JavaScript will load the entire image to check it. You might want to adapt it to make it more efficient.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Command prompt [ 4 Answers ]

I have looked into the windows/system32 folder and the files ftp, ipconfig, ping are there... why is the command prompt not recognising these commands then? Could someone give me some input to get these commands working in my command prompt?

Yahoo Prompt password [ 2 Answers ]

Hi all, I have enternet explorer v 6.0 and winxp with sp2 with latest update And when I try to login by my Yahoo ID it always promt me enter the password again, or ask me to enter my id and password And when I login to my group and try to see anything it always asking me about my password. This...

MS DOS prompt screen [ 6 Answers ]

How do you get onto your MS DOS prompt screen on Windows XP? I'm trying to get a dot address for a domain name.

Need help getting rid of popup ads. [ 7 Answers ]

:( I'm a new member and have joined out of hope and desperation. For some reason, I keep getting pop up ads that seem to be Internet Explorer related - and they are coming up even when I'm offline. One (the worst) is http://dnaads.com - but several others have made an appearance. Sometimes, this...


View more questions Search