RealisticGraphics
Nov 17th, 2002, 09:31 AM
I'm currently working on an intranet project for a local company that has no web enabled servers so I'm limited to client side scripting and it is IE 5+ specific.
My issue is that most of the pages work off the location objects search property (location.search). Everything works great until the user tries to use the Back button on the browser. Apparently IE does not create a history entry for local pages that are being reloaded with different search values on the location string. To better understand this issue, take a look at the sample code below and remember to use IE 5+.
<script language="JavaScript">
var sString = location.search
sString = sString.substring(sString.indexOf("=") + 1)
if(sString == "1"){
document.writeln("Hello 1");
}
if(sString == "2"){
document.writeln("Hello 2");
}
if(sString == "3"){
document.writeln("Hello 3");
}
</script>
<br><br>
<a href="test.htm?TestValue=1">Test History 1</a><br>
<a href="test.htm?TestValue=2">Test History 2</a><br>
<a href="test.htm?TestValue=3">Test History 3</a>
Now after clicking on the links a few times you'll notice that it doesn't add history for the clicks you made. But if you go and change TestValue on your own by typing it on the URL and hitting enter, it does add history.
I would like to be able to get around this either by forcing IE to add the page to the history so that the back button works or by intercepting the Back buttons event and telling it where to go.
Right now my only options that I can think of is to use a cookie to store my own set of history within the intranet and add back/forward buttons on the page some place. However I would like this to be a last resort, as I'm sure it wouldn't be pretty and I'm even more sure that end users are going to go a click on the back button and then call when it doesn't work right :rolleyes:
Any help would be greatly appreciated. Thanks in advance.
My issue is that most of the pages work off the location objects search property (location.search). Everything works great until the user tries to use the Back button on the browser. Apparently IE does not create a history entry for local pages that are being reloaded with different search values on the location string. To better understand this issue, take a look at the sample code below and remember to use IE 5+.
<script language="JavaScript">
var sString = location.search
sString = sString.substring(sString.indexOf("=") + 1)
if(sString == "1"){
document.writeln("Hello 1");
}
if(sString == "2"){
document.writeln("Hello 2");
}
if(sString == "3"){
document.writeln("Hello 3");
}
</script>
<br><br>
<a href="test.htm?TestValue=1">Test History 1</a><br>
<a href="test.htm?TestValue=2">Test History 2</a><br>
<a href="test.htm?TestValue=3">Test History 3</a>
Now after clicking on the links a few times you'll notice that it doesn't add history for the clicks you made. But if you go and change TestValue on your own by typing it on the URL and hitting enter, it does add history.
I would like to be able to get around this either by forcing IE to add the page to the history so that the back button works or by intercepting the Back buttons event and telling it where to go.
Right now my only options that I can think of is to use a cookie to store my own set of history within the intranet and add back/forward buttons on the page some place. However I would like this to be a last resort, as I'm sure it wouldn't be pretty and I'm even more sure that end users are going to go a click on the back button and then call when it doesn't work right :rolleyes:
Any help would be greatly appreciated. Thanks in advance.