Moockigreeged
New Member
My question is, how can I test if a background-image has loaded properly?
Essentially I have some divs, \[code\]<div id="photo" style="background-image:url('someURL')">\[/code\] and some get an access denied error, or don't exist, I need to know when so I can avoid having no background image.
I know if they were images I could use \[code\]$("#image").error(function(){});\[/code\] but I, frustratingly can't here, and calling \[code\]css.("background-image")\[/code\] doesn't yield an error, which I thought it might, it just returns the completely useless url.
My other thought was to use the URL to generate a hidden image element, and test if that loads correctly, but I will be dealing with a lot of images and i'd rather have a more elegant solution.
If anyone knows how I can test that a background image, or image URL, returns an image, I'd be happy.
Essentially I have some divs, \[code\]<div id="photo" style="background-image:url('someURL')">\[/code\] and some get an access denied error, or don't exist, I need to know when so I can avoid having no background image.
I know if they were images I could use \[code\]$("#image").error(function(){});\[/code\] but I, frustratingly can't here, and calling \[code\]css.("background-image")\[/code\] doesn't yield an error, which I thought it might, it just returns the completely useless url.
My other thought was to use the URL to generate a hidden image element, and test if that loads correctly, but I will be dealing with a lot of images and i'd rather have a more elegant solution.
If anyone knows how I can test that a background image, or image URL, returns an image, I'd be happy.