mstram
mstram

Reputation: 592

How to access DOM (and /or window.document object) of a popup in Chrome extension script?

I'm working on a Google Chrome 'context' script

From the Chrome console, or a 'normal' tag, I can do :

win1 = window.open('some url'); 
b1 = win1.document.body.innerHTML; 

But from a chrome 'context' script, it fails with

Uncaught TypeError: Cannot read property 'document' of undefined

What is the "magic incantation" I need ?

This seems to be close to what I need, but it doesn't show where to put code to have the popup return a dom element Get DOM elements of a popup for jQuery manipulation

I don't fully understand the code there (nested scopes and things), so I'm trying to figure out where I'd put something like:

var getStuff = $('#baz').html();

Mike

Upvotes: 0

Views: 2272

Answers (1)

Naftali
Naftali

Reputation: 146310

You can only do what you propose IF both urls are in the same domain.

Otherwise you have cross domain issues and chrome (and most other browsers) do not allow for it.

Upvotes: 1

Related Questions