Forum Discussion
I'm fairly sure there is no direct way to detect if the page is within an iframe on the server (i.e. with FreeMarker code). However, you may be able to infer it based on the referrer (which is stored in the http.context object: http://lithosphere.lithium.com/t5/developers-knowledge-base/http-request-FreeMarker-context-object/ta-p/9323).
Normally the referrer will give you the URL of the page (internal or external) that linked to the community page currently being requested. However, if the page is embedded in a frame (or iframe) it will normally give you the URL of page containing the iframe. You may be able to use this information to infer whether or not the page is being loaded in an iframe.
Bear in mind that, even with this approach, it is very easy to spoof the referrer.
Hi Nathan
Thanks, that would work if i were only loading the iframe once, however I need to detect when the page is still in the iframe even after the user navigates around the embedded site using internal links. In that case the referrer is no longer from the iframe.
I guess it's not surprising that freemarker would not have access to the DOM since it operates on the server and has already done its work by the time the window is loaded into the frame.
Thanks anyway
Chris