Is there any way to add some code inside another html file with javascript like
document.getElementById("demo").innerHTML
yes it is, take a look here https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
// Create a new paragraph element, and append it to the end of the document body
var p = document.createElement("p");
document.getElementById("demo").appendChild(p);
a.htmlandb.html. Insidea.htmldo you want to write some JavaScript code that modify the html inb.html? Is this your question?