I inject an <iframe>
on an origin webpage (youtube.com).
What I want is to:
- Send an HTTP request to website A.
- Website A returns a json response.
- Update the iframe on origin webpage.
I just can't find a way to update iframe from content script.
Part of my manifest.json:
"content_scripts": [
{
"matches": ["https://www.youtube.com/watch?v=*"],
"js": ["jquery-2.2.3.min.js", "content_script.js"],
"all_frames": true,
"run_at": "document_end"
}
],
Part of my content script:
var iFrame = document.createElement ("iframe");
iFrame.src = chrome.extension.getURL("/template.html");
$('#watch-header').after(iFrame);
the result of above code:
<iframe src="chrome-extension://gdjehplmmeijdoijcnpbehoghnifhmib/template.html"></iframe>
I need an iframe so my image inside the template.html can correctly display.
sendMessage
doesn't work, contentDocument
also not working.
How to update the iframe anyway?