View Full Version : Select certain text within page?

09-22-2006, 09:10 AM
Hi - I'm currently trying to make a javascript/ajax powered news system that will dynamically bring the first three news titles from another page.

The ajax example here: http://www.dhtmlgoodies.com/scripts/ajax-dynamic-content/ajax-dynamic-content.html

Seem to do half the stuff and I basically need to know how I can select the text from the first three <h1> tags and display them in a list?

Is this remotely possible? I think it'll need some seriously clever person, but I've got a sneaky feeling it might be doable!

Many thanks.

09-22-2006, 10:15 PM
Without even looking at the pages, you can select text using DOM scripting.
You want to look at the different nodes in the HTML tree.


Depening on the structure of the tree, will depend on how far you need to look. You'll prob want to get an array of all your H1 elements and loop through them grabbing the child node value. If you have it setup to request the document, displaying them should be pretty easy.