PDA

View Full Version : Dynamic Ajax Content: Specifying DIV ID of target page in HTML markup?



Sputnik
02-21-2011, 09:29 AM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:

An addition to this script was added here (http://www.dynamicdrive.com/forums/showthread.php?t=60951&goto=nextoldest) that allows you to fetch only the content from a specific <div> on the target page, which is very useful. The DIV ID is specified in the Javascript file and not in the markup on the original HTML page.

Is there a way of including a variable in the HTML link that specifies the DIV ID on the target page?

Something like this:


<a href="javascript:ajaxpage('ExternalPage.html #SpecificDIV', 'rightcolumn'); loadobjs('Style.css');">Link1</a>

...where "#SpecificDIV" was the name of a specific DIV on the target page.

This would allow there to be multiple links on the page without attaching multiple versions of the Javascript file.

I hope I phrased that okay. I'm new to Javascript and Dynamic Drive.

Thanks everyone for a totally awesome resource.

Sputnik

oldmanInAz
02-22-2011, 06:43 PM
Exactly what I want to do as well.
If javascript can call up an ID within the same page, then it should also be able to call up a specified ID on ANY external page.
As I do not see the reason to write and load hundreds or thousands of individual pages. This is why we have anchors.

Taking DD's own script, put all three of the cars and information into one page.
Give each car a unique ID and call on that.

It certainly would make life easier.

Sputnik
02-22-2011, 07:08 PM
This addition would make the script very powerful!
The nice thing is the whole target page would load, not just the required <div>, so the next div that gets fetched from the same page would already be loaded! I guess this could be a disadvantage if the target page has a lot on it.

I think it's a fairly simple thing to add. I've been thrashing away at the code, trying to get the thing working, but alas my Javascript knowledge is rather sad :eek: I guess this is a good way to learn!

Any help from the code-guru's would be much appreciated! :cool: