469,271 Members | 1,554 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Multiple onload problem

On this page:
http://jimpix.co.uk/default-ajax1.asp

When viewed in IE6, only the wallppaper ajax section (which is 1 of 4 ajax sections, along with ecards / news / photo ecards and wallpapers), loads.

But in Firefox, they all load, when first loading the page.

I am using this method to load all of the functions on first loading the page:
http://www.netlobo.com/wom.html

My javascript functions are at the bottom of the page. Could the problem be to do with my first function - since this issue seems to be browser specific.

Thanks

Expand|Select|Wrap|Line Numbers
  1. function GetXmlHttpObject() {
  2.   var xmlhttp;
  3.   if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
  4.     xmlhttp = new XMLHttpRequest();
  5.     //if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
  6.   } else if (window.ActiveXObject) { // IE
  7.       try {
  8.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  9.       } catch (e) {
  10.           try {
  11.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  12.           } catch (e) {}
  13.       }
  14.   }
  15.   if (!xmlhttp) {
  16.     alert('Cannot create an XMLHTTP instance');
  17.     return false;
  18.   }
  19.   return xmlhttp;
  20. }
  21.  
  22. var http = GetXmlHttpObject();
Mar 18 '08 #1
7 1828
acoder
16,027 Expert Mod 8TB
womAdd() requires strings. Put quotes around the function call.
Mar 20 '08 #2
Thanks for the reply. I have changed that, but for some reason, the page works fine in Firefox, when it first loads, but again, in IE6, it only displays the last of the 4 functions - the one in bold.

[HTML]<script type="text/javascript" src="_wom.js"></script>
<script type="text/javascript">
womAdd("sendRequest(MyCurrentVar + ',' + MyCurrentCat)");
womAdd("sendPhotoRequest(MyPhotoVar)");
womAdd("sendNewsRequest(MyNewsVar)");
womAdd("sendWPRequest(MyWPVar)");
womOn();
</script>[/HTML]

And if I comment out the bold line (calling the 'sendWPRequest' function), IE6 will display the 3rd function, but ignore the 1st and 2nd!

I uploaded the revised page again:
http://jimpix.co.uk/default-ajax1.asp

Thanks again

Jim
Mar 20 '08 #3
acoder
16,027 Expert Mod 8TB
It seems that IE6 is overwriting the onload. Try using this script and see if it makes a difference.
Mar 22 '08 #4
Thanks acoder, again, for your helpful suggestion and feedback.

I gave it a try, but would you believe it, just the same result:
http://jimpix.co.uk/default-ajax1a.asp

I think that's the 4th method I've tried now:

1. multiple list on the onload in the body tag:
[HTML]<body onload="sendRequest(MyCurrentVar + ',' + MyCurrentCat);sendPhotoRequest(MyPhotoVar);sendNew sRequest(MyNewsVar);sendWPRequest(MyWPVar);">[/HTML]

2. Use the window.onload:
Expand|Select|Wrap|Line Numbers
  1. window.onload = function()
  2. {
  3.     sendRequest(MyCurrentVar + ',' + MyCurrentCat)
  4.     sendPhotoRequest(MyPhotoVar)
  5.     sendNewsRequest(MyNewsVar)
  6.     sendWPRequest(MyWPVar)
  7. }
3. Use the NetLobo option:
http://www.netlobo.com/wom.html

4. Use Simon Wilson's option:
http://simon.incutio.com/code/js/addloadevent/

Do you think it just can't be done?

Thanks again for your help

Jim
Mar 22 '08 #5
acoder
16,027 Expert Mod 8TB
Then it must be that you're reusing the http-request object, so it doesn't finish one and starts another. Either use different variables for each one or wait for one to finish before making another request using the same variable.
Mar 22 '08 #6
Dear acoder,

you are a star! Thank you so much for your help. That was the problem all along. I created different variables for each function, and it works a treat now, in IE6 and Firefox. Thank you again, what a helpful person!

Jim
Mar 22 '08 #7
acoder
16,027 Expert Mod 8TB
You're welcome. Glad it's working now :)
Mar 23 '08 #8

Post your reply

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

Similar topics

reply views Thread by Richard Payne | last post: by
2 posts views Thread by Emmanuel | last post: by
4 posts views Thread by Matt Ratliff | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.