Jump to content

Trouble With SetTimeOut, Function, & DHTML History In Internet Explorer


webster08

Recommended Posts

So I created this script and it works perfectly offline, but when I put it on a server; for some reason it will not work.

 

What does the script supposed to do; you might be asking right now. Well it is supposed to detect DHTML Browser History for AJAX; so that the: back, forward, and refresh navigation buttons on a browsers toolbar will make it easier for someone to maneuver through AJAX Pagination with their browser.

 

The issue is in IE, when you click the browser "back" button; for some reason it is not detecting the hash in the URL (at least it's not detecting it when it is on a server; offline works fine).

 

The pagination I created is mostly for demo purposes; too let you guys take a look at this and hopefully tell me why this is happening.

 

Here is the code for the DHTML Browser History Detection.....

 

<script type="text/javascript">

// DHTML Browser History Storage Detection

var i = 0;

function deploy()
{
var local = document.location.href.split("#")[1];
if (local == undefined)
{
local = 1;
}
if(local != undefined && local != i)
{
alert("AJAX Triggered!"); // ajax sends request to server side file
i = local;
}
setTimeout("deploy()", 1000);
}

window.onload=function() {
deploy();
}
</script>

 

And here is the code for the demo AJAX Pagination.....

 

<script type="text/javascript">

// AJAX Simulated Pagination

for (i=1;i<=10;i++) {
if (i != 10) {
document.write(" <a name=\""+i+"\" href=\"#"+i+"\">"+i+"</a> |");
}
else {
document.write(" <a name=\""+i+"\" href=\"#"+i+"\">"+i+"</a>");
}
}
</script>

 

when i click the back navigation button on the menu bar; in the the title of the tab; it say "404 Not Found". is there something about this that is causing my function not to fire? also there is not an error in IE; so i have no idea what is causing the issue.

 

Can someone tell me why this would work fine in IE offline, but why it will not work online (on a server/web host - when in a file manager)?

 

can anyone look at my code and tell me why it would work offline, but not online? because i do not understand why this occurs.

Link to comment
Share on other sites

  • 3 months later...

Fixed:

var i = 0;

function deploy()
{
var local = document.location.href.split("#")[1];
if (local === undefined)
{
local = 1;
}
if(local !== undefined && local !== i)
{
alert("AJAX Triggered!"); 
i = local;
}
setTimeout(deploy(), 1000);
}

window.onload=function() {
deploy();}

 

Fixed:

for (i=1;i<=10;i++) {
if (i != 10) {
document(" <a name=\""+i+"\" href=\"#"+i+"\">"+i+"</a> |");
}
else {
document(" <a name=\""+i+"\" href=\"#"+i+"\">"+i+"</a>");
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.