I managed to solve this problem, dropping the <img>
idea in favor of CSS and classes:
<div id="blockui-animated-content" style="display: none; padding: 15px">
<div style="margin-right: 7px; vertical-align: middle; display: inline-block">
<i class="icon-cog icon-spin icon-3x"></i>
</div>
<div style="font-size: 28px; vertical-align: middle; display: inline-block">
Proszę czekać! Operacja w toku...
</div>
</div>
Changing blockUI plugin call to:
$.blockUI.defaults.message = $('#blockui-animated-content');
$.blockUI.defaults.css.top = '45%';
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
$(window).on('beforeunload', function(){$.blockUI();});
Now, all works just fine, both in AJAX and URL change. Unfortunately, this doesn't answer the question: "Why Firefox and Chrome doesn't display images from <img>
tags in onbeforeunload
event?".