From c3cba034c8009b65c25dd4ef5f54b18d9c8ee7d4 Mon Sep 17 00:00:00 2001 From: Thomas BrĂ¼derli Date: Tue, 24 Jul 2007 09:54:33 +0000 Subject: Improved it_state with Safari support --- itjs/state.html | 6 +++--- itjs/state.js | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'itjs') diff --git a/itjs/state.html b/itjs/state.html index 3029932..36f36c0 100644 --- a/itjs/state.html +++ b/itjs/state.html @@ -16,16 +16,16 @@ function state_onload() else window.setTimeout(state_onload, 90); } - window.onbeforeunload = state_onbeforeunload; + window[(document.all?'onbeforeunload':'onunload')] = state_onbeforeunload; } function state_onbeforeunload() { - if (parent.it_state) + if (parent.it_state && !parent.it_state.it_state_saved) parent.it_state.store_state(); } -
+
EOF ?> diff --git a/itjs/state.js b/itjs/state.js index 9521093..73e41cb 100644 --- a/itjs/state.js +++ b/itjs/state.js @@ -8,6 +8,7 @@ var it_state = { it_iframe: null, it_history_field: null, +it_state_saved: false, it_store_handlers: [], it_restore_handlers: [], @@ -44,12 +45,18 @@ register_restore_handler: function(p) */ new_history_entry: function(p) { - // ED('it_state::new_history_entry()'); + this.store_state(); + this.it_state_saved = true; if (!this.it_iframe && !(this.it_iframe = document.getElementById('it_state'))) ED('it_state::new_history_entry(): it_state object not found!'); - this.it_iframe.src = "/itjs/state.html?t="+it_now(); + var idoc; + if (idoc = it_get_iframe_document(this.it_iframe)) + { + idoc.title = document.title; + idoc.forms[0].submit(); + } this.it_history_field = null; }, @@ -64,18 +71,18 @@ restore_history: function() var idoc = it_get_iframe_document(this.it_iframe); this.it_history_field = idoc ? idoc.getElementById('state') : {}; // Work-around IE5 not returning iframe document + this.it_state_saved = false; if (this.it_history_field.value) { var res = eval('({' + this.it_history_field.value + '})'); - // ED('it_state::restore_history(): restoring these settings:', res); for (var key in res) this[key] = res[key]; } for (var i in this.it_restore_handlers) { - if (this.it_history_field.value || (this.it_restore_handlers[i].initial && (!idoc || !it_get_iframe_document(this.it_iframe).location.href.match(/t=/)))) + if (this.it_history_field.value || (this.it_restore_handlers[i].initial && (!idoc || !idoc.location.href.match(/s=/)))) this.it_restore_handlers[i].object[this.it_restore_handlers[i].method](); } }, @@ -103,7 +110,6 @@ store_state: function() ser[ser.length] = key + ':' + ((type == 'string') ? "'" + value.replace(/([\\'])/g, '\\\1') + "'" : value); } - // ED('it_state::store_state()', ser); this.it_history_field.value = ser.join(','); }/* NO COMMA */ } -- cgit v1.2.3