How to access the Object window from another page

Asked

Viewed 24 times

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 he made the request, this is possible?

Example as I am using.

$('#link').click(function(){
   $.ajax({
      url: 'www.google.com',
      type: 'GET',
      success: function(res) {
       var x = JSON.stringify(res.window);
       alert(x);
      }
    });
});
  • Not possible (at least as far as I know).

1 answer

0

I can capture html

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

var meuIframe = document.getElementById('meuIframe');
var objetoWindow = meuIframe.contentWindow;
  • I think the www.google.com was only an example, since the request would be made to https://www.domain.com/www.google.com due to the lack of //

Browser other questions tagged

You are not signed in. Login or sign up in order to post.