Background
I have a website that uses iframes to display content. If the URL to a content is called directly by the user it should be "jailed" into the main page.
The main page provides a header and a footer as well as the navigation menu. There is one iframe named contentframe. All links in the navigation (and footer and stuff) target this frame.
My Solution for "jailing"
First I find out whether the page is already jailed via javascript (that's simply done with something like var jailed = (window.self != window.top);
where jailed will be true if the page is "jailed" already.
Next I redirect (using javascript) to the main page with a parameter called referrer passing it the URL of the page which should get "jailed". This PHP script reads this parameter and sets it as the src argument of the iframe.
This way the main page is loaded within the iframe.
This way I can directly link to a content and after only one reload everything will be displayed just fine. But I have questions regarding some issues.
My Questions
Are there seo problems?
I think, that google can index the contents of my site (links provided at least by the sitemap.xml and of course through the navigation links). But what about this javascript redirect? It's not cloaking, but is it problematic? Will Google punish me for that somehow?
I found out, that it's hard to find some info material for this topic.What about best practices?
I know how to do what I want to do technically, but how about best practices? I couldn't find anything so far, but maybe some of you had to deal with that. Or is my solution perfectly fine?
Note1
I know iframes are not a very elegant way for displaying the content (from the same domain), but I'm stuck with it and I must deal with it, so please no "do not use iframes comments" :-)
Note2
Please, no opinions. I'm quite sure there are some facts on how to do this the best way.
Note3
The following link describes that the intent is very important. In a way I'm showing different content to GoogleBot than to my user, technically. But the content really stays the same only it is decorated a bit. But what does GoogleBot say?
Cloaking and/or Sneaky Redirects