<a href="https://wwwa.applyonlinenow.com/" target="_blank">https://wwwa.applyonlinenow.com/</a><br />_________________<br />"Any purchases made by me are on the grounds that I own the original, if not the <a href="http://www.someurl.co.uk" target="_blank"><font color="#000000">backup</font></a> will be destroyed within 24 hours"
<a href="https://wwwa.applyonlinenow.com/" target="_blank">https://wwwa.applyonlinenow.com/</a><br />_________________<br />"Any purchases made by me are on the grounds that I own the original, if not the backup will be destroyed within 24 hours"
Any ideas?
Thanks
Last edited by JayBird on Thu Jun 01, 2006 9:40 am, edited 1 time in total.
var links = document.evaluate("//a", document, NULL, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i = 0, l = links.snapshotLength; i < l; i ) {
var link = links.snapshotItem(i);
// do something to link...
}
but if your Array proto-object is extended with some user defined methods (like forEach), in IE they would show up as array elements. Not applicable here, but nevertheless good to know.
i.e. completely removing the 'a' and the 'font' tags from these words. http://www.someurl.co.uk could be any url and the word 'backup' could be any word
let me clarify:
you need to find every link with target attribute equal to "_blank" that contain font element and remove the link together with font subelement, preserving the content of the font subelement.
Weirdan wrote:let me clarify:
you need to find every link with target attribute equal to "_blank" that contain font element and remove the link together with font subelement, preserving the content of the font subelement.
Is it right?
Yes, nearly correct.
The target element will always be there, but it isn't a unique factor. Other links could have target="_blank" too
var links = document.evaluate(
"//a[count(font)=1 and @target]", // select every A elt which have exactly one FONT subelt and target attribute
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null
);
for(var i = 0, l = links.snapshotLength; i < l; i++) {
var link = links.snapshotItem(i);
var text = link.firstChild.innerHTML; // this should be the content of font subelement
link.parentNode.replaceChild(document.createTextNode(text), link);
}