Get Data From One Html File And Display It Using Another Html File
I have 2 html files. I want to take the innerHTML of an element of the 1st HTML file and display it in the 2nd HTML. This is the 1.html file
DATA
<Solution 1:
Here is code which may help you. In 1.html:
<h1id="data">Main</h1><ahref="2.html"><buttononclick="go()">GO</button></a><scriptsrc="action.js"></script>
In 2.html:
<h1id="display"></h1><scriptsrc="action.js"></script><script>disp();</script>
In action.js:
functiongo() {
var data = document.getElementById("data").innerHTML;
localStorage.setItem("data ", data );
}
functiondisp() {
document.getElementById("display").innerHTML = localStorage.getItem("data");
}
Post a Comment for "Get Data From One Html File And Display It Using Another Html File"