summaryrefslogtreecommitdiff
path: root/itjs
diff options
context:
space:
mode:
Diffstat (limited to 'itjs')
-rw-r--r--itjs/state.html6
-rw-r--r--itjs/state.js16
2 files changed, 14 insertions, 8 deletions
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();
}
</script>
</head>
-<body onload="state_onload()"><form action=""><input type="hidden" id="state" value=""></form></body>
+<body onload="state_onload()"><form action="/itjs/state.html" method="get"><input type="hidden" id="state" name="s" value=""></form></body>
</html>
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 */
}