I know that I can run a line of javascript code after the page loads on an iPad with UIWebView (which is what I am using), but I do not know what I could type to go through and remove all of the tags. I also would like to be able to do this to only certain parts of the page e.g. only remove tags within a certain tag.
Share
You can get all elements by tag name using
document.getElementsByTagName(). All links have the tag namea. You can visually remove them by setting theirdisplaystyle tonone.To remove elements of a certain tag within a certain tag, just invoke
getElementsByTagName()on the element in question. Suppose that you want to hide all links inside a<li>only:The
element.parentNode.removeChild(element)is also a good one, but it doesn’t work nicely inside a standardforloop. You need to loop backwards:Update as per the clarified functional requirement: you thus want to replace the link element with a text node representing the link’s original content? You can use
Node.replaceChild()for this. Here’s a kickoff example: