From 7ce3264c7918ba42e174c99f5c070cdc82fd8c5d Mon Sep 17 00:00:00 2001 From: "Anders S. Mortensen" Date: Thu, 28 Dec 2006 13:12:37 +0000 Subject: [PATCH] Back button works in firefox. --- www/test1/index.html | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/www/test1/index.html b/www/test1/index.html index 4f786bd..d6d548c 100644 --- a/www/test1/index.html +++ b/www/test1/index.html @@ -21,6 +21,8 @@ var showtimer; var termtimer; var stattimer; var startrec; +var session_cells = Array('query'); +var old_session = session_read(); function GetXmlHttpObject() { @@ -314,7 +316,6 @@ function start_search() function session_encode () { - var session_cells = Array('query'); var i; var session = ''; @@ -329,37 +330,63 @@ function session_encode () } -function session_decode (session) +function session_restore (session) { + var fields = session.split(/&/); + var i; + + for (i = 1; i < fields.length; i++) + { + var pair = fields[i].split(/=/); + var key = pair[0]; + var value = pair[1]; + var cell = document.getElementById(key); + + cell.value = value; + } } function session_read () { - var ses = document.location.href; - return ses.replace(/.*#/, ''); + var ses = window.location.hash.replace(/^#/, ''); + return ses; } function session_store (new_value) { - var location = document.location.href; - - location = location.replace(/#.*$/, ''); - location += '#' + new_value; - document.location.href = location; + window.location.hash = '#' + new_value; } -function update_history () { +function update_history () +{ var session = session_encode(); session_store(session); + old_session= session; } +function session_check () +{ + var session = session_read(); + + clearInterval(url_surveillence); + + if ( session != old_session ) + { + session_restore(session); + start_search(); + } + url_surveillence = setInterval(session_check, 200); +} + + +var url_surveillence = setInterval(session_check, 200); -- 1.7.10.4