0

I have a html page structure something like this,

<body>
  <table id = "a">
    <tr>
      <td id = "x"></td>
      <td id = "b">
         <div id = "y"></div>
         <div id = "c">
            <iframe id = "d"/>
          </div>
      </td>
  </tr>
</table>
</body>

I have tried using getElementById() on all elements then,

var iframe = document.getElementById('d');
iframe.src = iframe.src;

But, the getElementById() returns null. Please help!

PS: iframe is from the same domain. Need strictly JS code. No JQuery please.

Edit: How can i access the iframe ?

HeXMaN
  • 113
  • 1
  • 11

2 Answers2

2
document.getElementById('some_frame_id').contentWindow.location.reload();

Look like a duplicate of here

Community
  • 1
  • 1
Deanmv
  • 1,191
  • 9
  • 13
0

try to using :

<body>
<table class= "a">
 <tr>
  <td class= "a"></td>
   <td class= "a">
     <div class= "a"></div>
     <div class= "a">
        <iframe class= "a"/>
      </div>
    </td>
 </tr>
 </table>
 </body>

and js :

document.getElementsByClassName("a");

Try it Yourself ยป

mody
  • 65
  • 2
  • 7