lundi 20 avril 2015

Find string with only partially known value

In an img tag, the src is not a constant value with each page load.

<img src="http:/foo.com/directory/id=(random alphanumeric string ID)">

The quantity of the alphanumeric string generated by the network that created it is generally just over 200 characters.

If this were the only img tag, I would just do getElementsByTagName, but there are plenty of img across the page source. Is there a way to target a tag source by only partial src contents, and then .innerHTML the ID number only? I imagine it would have to be written in such a way that it goes until it encounters the " at the end.

Aucun commentaire:

Enregistrer un commentaire