1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<script type="text/javascript">
function addEvent(e, evType, fn) {
if(e.addEventListener) {
e.addEventListener(evType, fn, false); // sans capture
return true;
} else if (e.attachEvent) {
var r = e.attachEvent("on"+evType, fn);
return r;
} else { return false; }
}
// ajoute un oberveur pour document.location.onchange
document.location.oldhref = document.location.href;
addEvent(window, 'focus', function() {
if(document.location.oldhref != document.location.href) {
document.location.oldhref = document.location.href;
if(document.location.onchange) document.location.onchange();
}
});
document.location.onchange = function() {
alert(document.location.href);
};
</script> |
Partager