webster08 Posted November 22, 2008 Share Posted November 22, 2008 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 https://forums.phpfreaks.com/topic/133739-trouble-with-settimeout-function-dhtml-history-in-internet-explorer/ Share on other sites More sharing options...
darkfreaks Posted March 1, 2009 Share Posted March 1, 2009 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 https://forums.phpfreaks.com/topic/133739-trouble-with-settimeout-function-dhtml-history-in-internet-explorer/#findComment-773988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.