Detect iframe request in rails application

I have an iFrame tool that should display in a different format than my page. So I want to detect requests from iFrame, how can I detect them from iPhone. Is it possible?

Is there a special header in the request header that I could use, or can I manually enter one?

Thanks Marcus

+4
source share
1 answer

When you receive a request from iPhone, a β€œUser Agent” -String will be sent, for example Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 in the request.user_agent variable. Finding this line for the iPhone may mean that the iPhone is visiting your page.

iframe is an HTML tag to include other pages in your page (for example, this button is used as Facebook). This has nothing to do with a particular browser; all modern browsers support this. You cannot tell on the server side whether your page was called in an iframe or not. You can use some kind of JavaScript in the client to find out if your current page is within the iframe and then send a notification to the server.

It would be best practice to add another parameter to your request, for example ?iframe=1 , and use this parameter in your controller.

+8
source

All Articles