上記エントリの内容ですが、prototype.jsにもちょっと関連します。
実は、prototype.jsの1.4ではwindowオブジェクトにunloadイベントのリスナを登録しています。これが、prototype.jsの1.6*1では登録しない作りになってます。そのため、prototype.jsをバージョンアップすると、戻るボタン時にAjaxが不正になると言う不具合が起こる可能性があります。
ただ、先に書いたキャッシュの問題もあるので、1.6のようにunloadは極力利用しない作りの方がベターだと思います。古いprototype.jsを利用している方は積極的にアップグレードしていいんじゃないかと思います。
以下、prototype.jsの1.4と1.6を検証する簡単なスクリプト*2です。
<html> <head> <script type="text/javascript"> var _logs = ""; window._addEventListener = window.addEventListener; window.addEventListener = function(type, listener, useCapture){ _logs += type + ": " + listener + "\n"; return window._addEventListener(type, listener, useCapture); } </script> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> Event.observe(window, 'load', function (){ document.write("<pre>" + _logs + "</pre>"); }, false); </script> </head> <body> </body> </html>
1.4の場合の実行結果
unload: function ()
{
if (!Event.observers)
return;
for (var i = 0; i < Event.observers.length; i++)
{
Event.stopObserving.apply(this, Event.observers[i]);
Event.observers[i][0] = null;
}
Event.observers = false;
}
load: function ()
{
document.write("
" + _logs + "
");
}
1.6の場合の実行結果
load: function (event)
{
if (!Event || !Event.extend || (event.eventName && event.eventName != eventName))
return false;
Event.extend(event);
handler.call(element, event);
}
load: function (event)
{
if (!Event || !Event.extend || (event.eventName && event.eventName != eventName))
return false;
Event.extend(event);
handler.call(element, event);
}