Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different layout for iframe

I have a rails app with content other websites need to access via iframe. The content should have a different layout when shown on the websites (no menu bar etc.) I made a new layout file called iframe.html.erb How can I check, whether the page is called form an external iframe so the right layout file is used?

like image 612
Arwed Avatar asked Dec 12 '22 16:12

Arwed


1 Answers

As far as I know when you doing

<iframe src="www.google.pl"></iframe>

you have no control over layout or styles of page display in iframe unless you own the page and can make it look whatever you like.

EDITED

If you displaying your own site go like this:

<iframe src="/some_site_that_i_can_change_code_in?from=iframe"></iframe>

and then in controller of some_site_that_i_can_change_code_in:

if params[:from] == "iframe"
  render :layout => "for_iframe"
else
  render :layout => "normal"
end
like image 68
Adrian Serafin Avatar answered Dec 31 '22 19:12

Adrian Serafin