javascript - How to use jQuery to detect loaded background image after inserting out CSS -


i had googled long time find out solution failed in end.

here comes detail problems below:

i have javascript code written jquery lib.

$('<link id="usercss" rel="stylesheet" href="'+link+'" type="text/css" charset="utf-8">').insertafter("title"); 

you can find out dynamically load css file somewhere else.

and , because file generated someone's server different person person, there may have random css segment this:

body,html {   background:#000 url(http://i43.tinypic.com/xxxx.jpg) top left no-repeat;   font-family:arial,verdana,sans-serif;   font-size:12px; } 

so , here comes problem ! hope can trigger onload event when background image loaded had tried ways no hope.

does have related experiences , give me hand !? :]

no example code, best can suggest extract full url in parentheses, create image object, set source url, , bind whatever action want onload image. i'm not 100% work, believe image downloaded once both background , new image object, firing event @ correct time.

you may need use event.special.load plugin in case image in background gets downloaded before image object created. because if happens, it'll coming cache onload event may or may not handle correctly.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -