How to access the object window from another page

0

I am making a request via Ajax, I can capture the html, but I wanted to have access to the object window of the page that made the request, is it possible?

Example how I'm using.

$('#link').click(function(){
   $.ajax({
      url: 'www.google.com.br',
      type: 'GET',
      success: function(res) {
       var x = JSON.stringify(res.window);
       alert(x);
      }
    });
});
    
asked by anonymous 12.11.2018 / 01:56

1 answer

0
  

I can capture the html

Can you? This request will not even be possible, because to make a request to another domain, that other domain must accept its address in the Access-Control-Allow-Origin header, or the browser itself will block the response. But if you used google just as an example, you can attach all the html that you received inside a <iframe> element to isolate it, and then access the window with

var meuIframe = document.getElementById('meuIframe');
var objetoWindow = meuIframe.contentWindow;
    
12.11.2018 / 02:22