1

Following the idea of load a page inside a div, as discussed in this post, I would like to retrieve information about a DOM element from this page that I just loaded.

If I run the code below located in test.php, I will be able to see a W3C page, loaded inside a div inside test.php page. Than I will have an alert "Undefined" if I try to retrieve information contained inside the Check "btn". I think it is because the element that I am looking for is not part of the test.php DOM.

So, how can I retrieve information from this element?

This is the code: test.php

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    </head>
    <body>
     <div> 
      <object type="text/html" data="http://validator.w3.org/" width="800px" height="600px" >
      </object>
     </div>
    </body>


</html>
<script>
    $(document).ready(function(){
        alert("ok");
        alert($('a[class=submit]').html()); //Element inside validator.w3.org not in test.php
    });
</script>
Community
  • 1
  • 1
IgorAlves
  • 5,086
  • 10
  • 52
  • 83
  • 1
    Aren't you asking about a page loaded inside (or *as*) an object? – isherwood Sep 25 '15 at 19:56
  • can you explain more what you want ? – Diptox Sep 25 '15 at 20:02
  • I have a page "https://validator.w3.org/" that I loaded inside a div in the test.php. Now I am trying use jquery to display some information from w3.org DOM elements. It is only a test. Only to check if it is possible to do that. – IgorAlves Sep 25 '15 at 20:11
  • can you try `$(window).load();` instead of `$(document).ready()` – indubitablee Sep 25 '15 at 20:27
  • Hi indubitalee, it not works. It seems that there are 2 DOMs. I dont know if ti possible. That means, the DOM from the test.php page it self and the DOM of the page that are loaded (in this case http://validator.w3.org/). So when I try to grab some information using jQuery I think the only DOM recognized is from test.php. I dont know if it is possible. – IgorAlves Sep 30 '15 at 12:38

0 Answers0