简体   繁体   中英

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM