hSATAC
hSATAC

Reputation: 301

How to get frame's current src using chrome extension?

I have a webpage which contains 2 frames:top and main. main frame is not under my domain, and it could be any websites.

Yes I can get $("#main").attr("src") but it could only reach the "first" src, not the "current" src.

And I know it's not possible to be done by javascript due to the security issue, so I am thinking creating a chrome extension to do it.

I tried with Content Script, but I think it can not do it because it's just add js to the page.

Is there anyone who could offer some advices? Thx

Upvotes: 2

Views: 1101

Answers (1)

serg
serg

Reputation: 111275

I can answer this part:

I tried with Content Script, but I think it can not do it because it's just add js to the page.

You just need to set "all_frames": true in the manifest:

"content_scripts": [ {
    "js": [ "script.js" ],
    "matches": [ "http://*/*", "https://*/*" ],
    "all_frames": true
} ],

this will inject scripts to each frame as well.

Upvotes: 1

Related Questions