将URL参数传递到iFrame源 [英] Passing URL Parameters into an iFrame Source

查看:322
本文介绍了将URL参数传递到iFrame源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个房地产网站,让人们可以选择搜索房屋并使用不同的选项缩小搜索范围,例如价格,位置,数量或房间等。

I am setting up a real estate website that will give people the option to search homes and narrow down the search using different options, such as price, location, number or rooms, etc.

目前,我已经创建了一个输出到类似于此URL的表单:

Currently, I have created a form that outputs to a URL similar to this:

www.websitename.com/search/url=www.sitetwo.com?param=1%param=2%param=3

该特定页面(www.websitename.com/search)加载iframe。我需要iFrame源来自搜索表单创建的URL的第二部分(www.sitetwo.com?param=1%param=2%param=3)。

That particular page (www.websitename.com/search) loads an iframe. I need the iFrame source to pull from the second part of the URL created by the search form (www.sitetwo.com?param=1%param=2%param=3).

我该怎么做呢?我假设它是一段javascript,但我的JS是有限的。因此,朝着正确的方向前进是非常棘手的。

How would I go about doing this? I assuming its a piece of javascript, but my JS is limited. So getting going in the right direction has been tricky.

编辑 - 为澄清添加

sitetwo.com URL是我必须使用的URL,因为它是房地产列表解决方案的一部分(基本上,它允许在我们的网站上显示来自第三方提供商的列表)。这是他们建议与他们的系统集成的方式。

EDIT - Added for Clarification
The sitetwo.com URL is a URL I have to use as it is part of the real estate listings solution (basically, it allows to display listings from a third party provider on our website). It is how they recommend integrating with their system.

这是一个类似于我想要实现的东西的网站:
http://tierraantigua.com

Here is a site doing something similar to what I am trying to achieve: http://tierraantigua.com

推荐答案

你不应该在iframe中允许任意URI。

You shouldn't allow arbitrary URIs in your iframes.

首先,将整个URI放入原始表单的一个字段中。这将确保URL将被编码,并且不会干扰其他GET参数。在目标页面获取值,然后使用 decodeURIComponent

First, put the whole URI into one field of the originating form. This will make sure the URL will be encoded and doesn't interfere with other GET parameters. On the destination page get the value and then use decodeURIComponent.

这篇关于将URL参数传递到iFrame源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆