Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails + iframe: Rendering another website in your rails application

I would like to render another website in my rails application. The html tag < iframe> seems to the this as I want. I was wondering how I could make this as smooth as possible. Do I need to make a new model? How do I pass parameters to the website I would like to render?

Thanks

like image 467
bdeonovic Avatar asked Jul 20 '11 17:07

bdeonovic


1 Answers

If you use an iframe, you'll only have minimal control of the page you render. You can pick the URL, and pass any params it takes by appending them to the URL itself. But anything requiring login / cookies / etc. will need to be done by the user - you can't set cookies for other sites, for obvious security reasons.

<iframe src="http://www.othersite.com/some/path?param1=value1&param2=value2">
    <p>Placeholder text; only shows up if the page DOESN'T render!</p>
</iframe>

That's a simple example, but it covers just about all iframes can do for you. If that's all you need, perfect, but if not, you're going to have to do something much more complex.

Hope that helps!

like image 163
Xavier Holt Avatar answered Sep 22 '22 15:09

Xavier Holt