jquery - Unable to set background-image property in "beforeunload" event -


i'm trying solve ie-problem of not animating .gif image, when displayed in beforeunload or unload events. step this answer, found not working, played little bit code.

i have come that:

var     spinner = $('.spinner-large'),     spinnerbackgroundimage = spinner.css('background-image');  console.log(spinnerbackgroundimage); console.log($('.spinner-large').css('background-image'));  spinner.css('background-image', spinnerbackgroundimage);  console.log(spinner.css('background-image'));  spinner.show(); 

this not working. spinner displayed, there no background image. , console contains:

backend-extra.js:97     url(http://127.0.0.1/images/spinner-large.gif) backend-extra.js:98     url(http://127.0.0.1/images/spinner-large.gif) backend-extra.js:102    none 

what missing? why can't set entire background-image property value jquery?

note, don't want set path image in background-image property, because know, how should this. i'm asking: why background-image property value reset none, when i'm trying change above method?

edit: here jsfiddle above problem. seems 100% beforeunload event-related issue. when clicking button, same code works fine, while when refreshing page or navigating other url, console have same output above -- property not set.

there should quotes around url:

background-image: url("http(...)spinner-large.gif"); 

invalid formatting reason enough turn none. otherwise might helpful create jsfiddle, codepen, that. not seem obvious behavior.

edit: beyond me, doesn't seem fault either. i'd suggest working around it. possible in ugly way, not animating background on ie. (gracefully degrading should okay anyway!)


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -