How to invoke a table from another HTML page

I work in a zoo. There are 2 pages that I created, namely test and test2 . I need to access the table that is present on test2 from test page . I guess I need to call this table some name. Is there any mechanism by which I can access this test2 table page with test .

+5
source share
2 answers

You can use LocalStorage ( http://www.w3schools.com/html/html5_webstorage.asp ) in javascript. What would you do is serialize the form data of test2 (for example, using JSON) and save it in LocalStorage , which can also get your other window, test.

For example, in test2 you have something like this:

 var tableHTML = document.getElementById("yourTableID").innerHTML; window.localStorage["sharedTable"] = tableHTML; 

And in test you will have:

 var tableHTML = window.localStorage["sharedTable"]; var table = document.createElement('table'); table.innerHTML = tableHTML; //now table will be just like what you would get in test2 window if you did document.getElementById('yourTableId'); 

Here is a view of a unique situation for demonstration ... I have two JSFiddles that represent your two windows / pages. Open the first link first, because it represents test2, which must be launched first in order to be available. Then open the 2nd and see the HTML table from another page to warn.

Open first (Page2): http://jsfiddle.net/mLy4tje2/

Open the second: (Page1); http://jsfiddle.net/qx2xodns/

+3
source

You can create the table as a separate html page and display it in the test and test2 using iframe tags.

iframe link

This is not a permanent solution. It is an idea to share html between two pages.

0
source

Source: https://habr.com/ru/post/1203186/


All Articles