I want to make a script that changes word/phrases on website to any other given by user. It needs to be done after user will put a first and second word to a form and execute it by clicking a button.
I want to use pure JS only. Can anyone help me?
function changeWord() {
  var fromWord = getElementById("inputText1");
  var toWord = getElementById("inputText2");
  var str = document.getElementsByTagName("body").innerHTML;
  var res = str.replace(var fromWord, var toWord);
  document.getElementById("body").innerHTML = res;
}<input type="text" name="inputText" id="inputText1" placeholder="Change from">
<input type="text" name="inputText" id="inputText2" placeholder="To">
<button onclick="changeWord()">Execute</button>
<p> Here is a text. </p>
<p> Here is another text </p> 
    