469,608 Members | 2,668 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,608 developers. It's quick & easy.

Ajax page reload state

Hi this is a newbie alert! This may seem really basic to most, but I am a total beginner, so please don't laugh, or gif me false info...lol I will use it.

I have an ajax container loading on my site http://www.defyinggravity.co.za/home.html

In Firefox the navigation works perfectly, but in IE, NS and Opera when I scroll to the bottom of a page and then select a new page to navigate to, then the page new page loads from the previous pages state (at the bottom or middle, where ever I had scrolled to)

here is the code for the ajax, can anyone help please?

Expand|Select|Wrap|Line Numbers
  1. var loadedobjects=""
  2. var rootdomain="http://"+window.location.hostname
  3.  
  4. function ajaxpage(url, containerid){
  5. var page_request = false
  6. if (window.XMLHttpRequest) // if Mozilla, Safari etc
  7. page_request = new XMLHttpRequest()
  8. else if (window.ActiveXObject){ // if IE
  9. try {
  10. page_request = new ActiveXObject("Msxml2.XMLHTTP")
  11. catch (e){
  12. try{
  13. page_request = new ActiveXObject("Microsoft.XMLHTTP")
  14. }
  15. catch (e){}
  16. }
  17. }
  18. else
  19. return false
  20. page_request.onreadystatechange=function(){
  21. loadpage(page_request, containerid)
  22. }
  23. page_request.open('GET', url, true)
  24. page_request.send(null)
  25. }
  26.  
  27. function loadpage(page_request, containerid){
  28. if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  29. document.getElementById(containerid).innerHTML=page_request.responseText
  30. }
  31.  
  32. function loadobjs(){
  33. if (!document.getElementById)
  34. return
  35. for (i=0; i<arguments.length; i++){
  36. var file=arguments[i]
  37. var fileref=""
  38. if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
  39. if (file.indexOf(".js")!=-1){ //If object is a js file
  40. fileref=document.createElement('script')
  41. fileref.setAttribute("type","text/javascript");
  42. fileref.setAttribute("src", file);
  43. }
  44. else if (file.indexOf(".css")!=-1){ //If object is a css file
  45. fileref=document.createElement("link")
  46. fileref.setAttribute("rel", "stylesheet");
  47. fileref.setAttribute("type", "text/css");
  48. fileref.setAttribute("href", file);
  49. }
  50. }
  51. if (fileref!=""){
  52. document.getElementsByTagName("head").item(0).appendChild(fileref)
  53. loadedobjects+=file+" " //Remember this object as being already added to page
  54. }
  55. }
  56. }
  57.  
  58. function MM_preloadImages() { //v3.0
  59.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  60.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  61.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  62. }
  63.  
  64. function MM_findObj(n, d) { //v4.01
  65.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  66.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  67.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  68.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  69.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  70. }
  71.  
  72. function MM_swapImgRestore() { //v3.0
  73.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  74. }
  75.  
  76. function MM_swapImage() { //v3.0
  77.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  78.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  79. }
Feb 7 '07 #1
2 1952
gyung
21
I helped someone with a similar problem before because I ran into a similar issue. I think you will find all the information you need here:

http://www.thescripts.com/forum/thread588665.html

Hope that helps.
Feb 7 '07 #2
Tx a stack will give it a bash

Have a great day!
Feb 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Yarco | last post: by
4 posts views Thread by Trip | last post: by
6 posts views Thread by Sabin.A.K, Bangalore | last post: by
10 posts views Thread by Steve | last post: by
reply views Thread by arunprabu | last post: by
6 posts views Thread by paladin.rithe | last post: by
1 post views Thread by empiresolutions | last post: by
10 posts views Thread by =?Utf-8?B?RGFuaQ==?= | last post: by
1 post views Thread by christian | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.