Jump to content

Add a script into html document


Osama ghanem

Recommended Posts

Please help me to add the below script :

<script>
paragraph = document.getElementById("test");
paragraph.innerHTML = '<span>' + paragraph.textContent.trim().replaceAll(/\.\s/g,'. </span><span>')
  + '</span>';

 sentences = paragraph.querySelectorAll('span');
sentences.forEach(s => s.addEventListener('click', highlight));
function highlight(event) {
  sentences.forEach(s => s.classList.remove('selected'));
  event.target.classList.add('selected');
}
</script>

into this html documnent

<!DOCTYPE html>
<html>
<head>
  <meta name="author" content="puravidaapps.com">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="jquery-1.8.0.min.js"></script>

  <script>
   function urldecode(str) {
    return decodeURIComponent((str+'').replace(/\+/g, '%20'));
  }
  </script>
</head>

<body>

  <script>
    
    var strdemo = urldecode(window.AppInventor.getWebViewString());
    
   
    $("<div>" + strdemo + "</div>").appendTo("body");
  </script>
</body>
</html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...