Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locating anchor tags

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

If you want to locate all the anchor tags relative to a webpage, it would seem that they would be found within the body of the document and in any .js file referenced by the document.

Where else, if anywhere, might they be found?

TIA

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Additionally, you could use this:

Code:
var anchorCollection = document.getElementsByTagName( "a" );

for ( var i = 0 ; i < anchorCollection.length ; i++ ) {
    // do something with each anchor
    alert( anchorCollection[ i ].href );
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
To better explain, this relates to a situation whereby you need to know the urls called by the webpage.

An IE object will provide the urls or hrefs called by the webpage - if there is a menu on the webpage with the urls contained in a .js file, you have to parse the .js file to recover the urls/hrefs, as there is no access via the IE object.

What would be helpful to know if a webpage might access urls/hrefs other than the two ways mentioned?

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
I see. You're referring to objects with their "onclick" (or either event) set to a JavaScript function, which could navigate away or change the action tag of a form, etc.

Hmmm. I think you could write a global event handler, and "inspect" all click events, for example, and then route them onward if you like, cancel them if you don't.

It's been a long time, but I think it was "window.captureEvents()" and ".routeEvents". You might google for those.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


If this post was helpful, click some ads! My personal site is also advertiser-supported. Hint, hint!
 
Thomas

Thanks for your further responses.

I would like to think that the two types of file, the webpage and .js file, if used, would be the only locations for urls accessed by the webpage, hence the request for confirmation of the theory.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top