When I tap on a paragraph with the following code in the web page in my app, it takes a long time to highlight or just locks up the app. What is wrong? It used to work fine.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			
			
				B4X:
			
		
		
		    <html>
    <head>
<link rel="stylesheet" href="../../style.css?dummy=" & DateTime.Now/>
<script type="text/javascript">
function createListener(){
    //    code to add the highlight on click event listener
    document.addEventListener('click', function(event){
        var element=event.target;
        var tagName=element.tagName.toLowerCase();
       
        if(tagName!=='div'){
            while(tagName!=='body' && (tagName!=='a' || element.name!=='')){
                //    find the clicked element's parent 'div' element to highlight (if the clicked element has no parent 'div' element then the loop will stop when the 'body' element is reached)
                element=element.parentNode;
                tagName=element.tagName.toLowerCase();
                if(tagName==='div'){
                    break;
                }
            }
        }
        if(tagName==='div'){
            if(element.className==='highlight'){
                element.className='';
            } else {
                element.className='highlight';
paragraph=element.innerText;
            }
        }
        var modifiedElements=document.getElementsByClassName('highlight'), text;
        if(modifiedElements.length>0){
            //    some elements have been highlighted so send the entire modofied page to a B4A Sub SaveHtml
            text=document.documentElement.outerHTML;
        } else {
            //    the page currently contains no highlighted elements send an empty string to the B4A Sub SaveHtml to indicate there is no need to save the page
            text=document.documentElement.outerHTML;
        }
        B4A.CallSub('SaveHtml', true, text);
while(tagName!=='a'){
    B4A.CallSub('SaveParagraph', true, paragraph);
    if(tagName==='div'){
        break;
    }
}
    }, false);
}
</script>
<title>Moroni 5</title>
    </head>
    <body onLoad="createListener()">
    <a href="../index.html" class="classname" style="width:auto;">Book of Mormon</a> <a href="index.html" class="classname" style="width:auto;">Moroni</a> Chapter 5
</div><p>
<a href="http://alumnihighschool.net/scriptures/bm/Moroni_5.mp3"><img src="../audio.jpg"></a>
</div><p>
</div><p> <i>The mode of administering the sacramental wine is set forth. [Between A.D. 400 and 421]</i>
</div><p> <div id="5: 1"></a> <href="5.html#5">1</a> The <a href="../../helps/morofn.html#5: 1a">manner</font></a> of administering the wine-Behold, they took the cup, and said:
</div><p> <div id="5: 2"></a> <href="5.html#5">2</a> O God, the Eternal Father, we ask thee, in the name of thy Son, Jesus Christ, to bless and sanctify this <a href="../../helps/morofn.html#5: 2a">wine</font></a> to the souls of all those who drink of it, that they may do it in <a href="../../helps/morofn.html#5: 2b">remembrance</font></a> of the <a href="../../helps/morofn.html#5: 2c">blood</font></a> of thy Son, which was shed for them; that they may witness unto thee, O God, the Eternal Father, that they do always remember him, that they may have his <a href="../../helps/morofn.html#5: 2d">Spirit</font></a> to be with them. Amen.
</body>
</html>