hello, I am trying to write a tiny snippet of js that prevents users from
accessing sub-frames of my site. the trick is, i want it to function such that
if a user goes to a sub-frame they are redirected to the top-level page with
the page they tried to access loaded in the correct frame.
The top-level page uses three iframes, the two of importance being
'contentFrame' and 'blogFrame' (as named in the html)

the code is broken up into three cases, the first is if the user tries to
access the blog directly, in which case they can simply be redirected to the
top level site which by default loads the blog into the 'blogFrame'.

the second case is if the user tries to access a single post page (the
substring(21,24) == '200' is just to do with how blogger formats its archive
pages), in which case I want to remember the accessed page (stored in the
'current' string), redirect to the top-level page, and then when the top-level
page loads, load the accessed page into the 'blogFrame'.

The third case is analagous to the second except that it is meant to load the
accessed page into the 'contentFrame'

I am not sure why this code doesn't work, any advice would be greatly
appreciated. Thanks!

--Code attached--

var topFrame = top.location.toString();
if(topFrame != "http://example.com/" && topFrame !=
"http://example.com/index.html"){
var current = window.location.toString();
if (current == "http://example.com/blog.html"){
window.location = "http://example.com/";
} else if (current.substring(21,24) == '200'){
var g = window;
g.location = "http://example.com/";
g.onLoad = function(){
g.frames['blogFrame'].location = current;
}
} else {
window.location = "http://example.com/";
g.onLoad = function(){
g.frames['contentFrame'].location = current;
}
}
}