I'm using the Dynamic Ajax Content script at http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm and wondering if there is a way that a link to a page with this script can be made to automatically load one of the included pages. Right now, I have the links in a menu, but I want to select the dynamic ajax content through an external url. Is this possible at all?

ddadmin

09-20-2006, 08:46 PM

Do you mean load content from a domain that's not your own (ie: http://www.yahoo.com)? Unfortunately due to security reasons, Ajax doesn't allow you get content outside the domain the script is on. This is mentioned on the script page as well:

Note: Due to security limitations, the external pages loaded must be from the same domain as the encompassing page. Any external .css and .js files associated with these pages, however, can be from any domain.

blm126

09-20-2006, 08:56 PM

Or do you mean that you link to page that will automatically load a url?

Strangeplant

09-21-2006, 12:48 PM

My thought was that if I have a lot of documents, instead of having them all accessable from a page menu, I could access them as needed from links in other pages as well by using a url something like this:
http://www.somesite.com/ajaxpage.html?file=nametoload&title=hotcontentI could even pass the title of the ajaxpage as a second variable, perhaps.

Then I could use a parser to digest the url. Just like you were passing variables from one page to another. I did find some code that does this (untried and not implemented):
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable) {return pair[1];}
}
alert('Query Variable ' + variable + ' not found');
}
</script>

Thanks for your input and code. I was planning on working on it, and didn't know how direct it was. The code worked just great! I modified the function to provide for a default load or 'seed' of the page when accessed as standalone like this:
function loadstart(){
var page = getQueryValue('page');
if(page != null)
{ajaxpage(page, 'contentarea');}
else
{ajaxpage('./default.html', 'contentarea');}
}This means that I can now do all sorts of things to access the content from other pages..........!
Thanks again for your help, I really appreciate it.