Reputation: 8214
I'm writing a Chrome Extension that changes calls to document.all so that it can be used in chrome.
However, the page consists of a script that writes a frameset using document.writeln. The frameset consists of one frame "FrameMain".
I'm having difficulties getting a variable pointing to the document in FrameMain.
I think the problem is that the FrameMain isn't created when document_start in chrome and it's not loaded when document_end occurs.
I'm currently using document_end as a starting point for my script:
$('FrameMain').ready(function () {
console.log("ready");
console.log(parent.frames);
console.log(parent.frames[0]);
});
The ready is printed when it seems the frame is loaded, it's not displayed immediately.
However, parent.frames returns a DOMWindow and parent.frames[0] is undefined.
How can I get a reference to the frames content?
Upvotes: 1
Views: 1169
Reputation: 8214
Solved it.
$('FrameMain').ready(function () {
console.log("ready");
$($("frame[name = 'FrameMain']")[0].contentDocument).find("body").append("<h1>Hello frame</h1>");
});
Using the frame selector and contentDocument was the key.
:)
Upvotes: 1