I'm trying to use JS to check if a string is on a page, and if it is, to inject some HTML into a DIV on the page. Here's my codewhat stupid mistake am I making?
Code:
<script type="text/javascript">
if (document.body.innerHTML.indexOf('My String'))
{
document.getElementById('target').innerHTML = 'Hello, world!';
}
</script>
<div id="target"></div>