user357936
user357936

Reputation:

Google Chrome Extension Adding iframe from source

I'm trying to load myframe.html inside an iframe and attach that iframe to the DOM of the current page. Is this possible, if myframe.html is part of my extension source?

I was thinking something like

var iframe = document.createElement("iframe");
iframe.setAttribute("src", "myframe.html"); //what would be my path here, if this were possible?
document.body.appendChild(iframe);

Upvotes: 1

Views: 2534

Answers (1)

Kinlan
Kinlan

Reputation: 16597

It should be possible, use a content script to inject javascript into the page and then use the chrome.extension.getURL() method to get the correct URL to your file hosted inside your extension

Upvotes: 6

Related Questions