1

When i call the "elem" var in the console it finds the element i want, but only after i run in the console it deletes the element not when the page is loaded.

<html>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <head>

    </head>
    <link rel="stylesheet" href="../../CSS/index.css">
    <body>
        <div>
        <?php

    $page=$_GET['id'].".html";

              echo '<iframe src="' .$page.'" id="'.$_GET['id'].'" frameBorder="0" width="70%" height="100%" align="left" scrolling="no" />';
              echo '</iframe>';
        ?>
    </div>

    <?php
    echo " <script>
    var elem=document.getElementById('".$_GET['id']."').contentWindow.document.getElementById('".$id."');
elem.parentNode.removeChild(elem);

    </script> ";
    ?>
    </body>

    </html>
Luis Luis Maia Maia
  • 681
  • 1
  • 10
  • 30

1 Answers1

2

Try with code, Hope it might help you.

document.getElementById('myframe1').contentWindow.document.getElementById('x');
sree
  • 389
  • 5
  • 17