I'm trying to do this in my local machine. It's just plain old html
file, literally the following:-
<html>
<head>
<title>Testing</title>
</head>
<frameset framespacing="0" frameborder="0" rows="20px,100%" border="0">
<frame src="index.html" name="mine_top" frameborder="0" scrolling="no", noresize="1">
<frame src="index.html" name="mine_inner">
</frameset>
</html>
But when I try to access the frames
in Chrome console
it's returning me an empty window object
. I'm trying to access the frames using this:-
window.frames["mine_top"] //or
window.frames[0]
Neither one returns the window
object that I'm expecting. And when I try to access the document
with window.frames[0].document
it throws me this error.
DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
I'm stomped. I can access frames
just fine which has same setup like reddit
does in the same browser but I can't for the life of me make mine work.
I found the answer. The page has to be served from the server. Looks like you can't access window.frames
just by opening that file.
I used node-static
package to serve up the page.