次のシナリオがあります。ユーザーがウェブサイトを離れようとしているときに確認メッセージを表示し、その時点で DOM も少し変更します。DOM を変更できるという事実にもかかわらず、画像は (プリロードされていても表示されません)。私も Ajax を試してみましたが、その瞬間にすべての接続がブロックされているように見えますか?
これが私のコード例です:
<div id="content">
my original content...
</div>
<button id="trigger">click</button>
<script type="text/html" id="template">
<div>
<img src="/css/images/dmbtest.gif"/>
</div>
</script>
<script type="text/javascript">
$(function(){
window.onbeforeunload = function() {
$('#content').html($('#template').html());
window.onbeforeunload = null;
return "some cool message";
}
});
</script>
助言がありますか?Ajax経由でコンテンツをロードできるようにしたいのですが... :(