Dynamically replace HTML element in UIWebView
I have HTML loaded in a WebView like this:
<html><head></head><body>before <myTag>Content</myTag> after</body></html>
I want to replace the element myTag
with custom text so that it looks like this:
<html><head></head><body>before ____MY_CUSTOM_TEXT___ after</body></html>
Also I cannot change the initial HTML. How can I do this using JavaScript?
My unfinished code:
var elements = document.getElementsByTagName( 'myTag' );
var firstElement = elements[0];
var parentElement = firstElement.parentNode;
var html = parentElement.innerHTML;
parentElement.innerHTML = html.replace(?????, '____MY_CUSTOM_TEXT___');
I don't know how to get the string value of the element to replace (?????).
+2
a source to share