View Full Version : Dynamic Drive AJAX content switcher mishap

07-26-2007, 06:33 PM

I'm posting here in an effort to cover my bases :p I'm using this ajax content loader (http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm) to load .htm files into a central div and I had a question:

One aspect of this script is that you must declare the external .js ans css files that you want applied to the page, like so:
<a href="javascript:ajaxpage('test.htm', 'contentarea'); loadobjs('external.css', 'feature.js')">test</a>
<div id="contentarea"></div>

Now I'm getting an error that I highly suspect is caused by this feature, or by how the ajax script works: When I load a page into the content area, scripts on both the 'parent' page and 'child' page (test.htm) go a bit wonky... however if I test them separately they work fine. Here is my question:

Theoretically: could the errors be a result of the .js files referencing the <body> tag, wherein once there is a link loaded into 'contentarea' there are technically Two <body> tags or Could they be a result of problems caused by them not being hardcoded into the .htm file but loaded via loadobjs('external.css', 'feature.js') or is there another reason for the mix-ups?

This post is an extension of a thread here:

I didn't want to repost so if you need to see it in action, that's the place :D

Thanks again :thumbsup:

07-28-2007, 09:24 PM
I have run into a similar problem with trying to call a particular external js file. I resolved it by adding the script to the html document, thereby avoiding the external call. Why it does that for certain scripts and not others I do not know.

You could test it by using this method, which will let you know if the script itself has any bugs.

07-29-2007, 01:51 AM
Actually that's precisely what i did :)

I think it has something to do with the script not being loaded fast enough, or the external .js being loaded (via the script) into the page AFTER it has been fully loaded, therefore throwing errors with any onload events (because as the page loads the scripts arent there yet... that and / or there being two <body> tags now