1

I want to store a table data in an html file and access the table data from another HTML file for which I am doing the following

<iframe id ="mytabledata" src="data.html" style="display:none"></iframe>
var thisvar = document.getElementById("mytabledata").contentWindow;
var gt=thisvar.document.getElementById("demovar");

I have a p tag demovar in the data.html file but it is returning NULL value and I cant access the file data.html.

What is wrong here?

Ivar
  • 6,138
  • 12
  • 49
  • 61

1 Answers1

0

Try this, Its working.

 <iframe width="500" height="300" src="./data.html" frameborder="0" allowfullscreen></iframe>

js:

  var row = document.getElementById("mytabledata");
  var content= (row.contentWindow || row.contentDocument);
  if (content.document)content = content.document;
  var cell = row.querySelector("#demovar");
Sridhar
  • 401
  • 7
  • 10