根据动态url设置iframeurl

有没有人知道一个javascript代码,它会检测页面的动态url(?q = Chicken),并将页面上iframe的url设置为https://www.google.co.uk/?#q=Chicken 。 (我实际上并没有制作谷歌搜索客户端!)

Get - Text added to Url set Url of iframe to https://www.google.co.uk/?#q=Chicken 

这将全部上传。

你需要这样的东西:

   

但它不适用于谷歌,因为它发送“X-Frame-Options:SAMEORIGIN”响应头:(

您可以在Javascript中使用location.searchhttps://developer.mozilla.org/en-US/docs/Web/API/URLUtils.search

所以一个例子是:

 $('iframe')[0].src = "http://www.google.co.uk/" + location.search; 

但是,Google不喜欢加入iframe。 你应该尝试另一个网站。

试试这个,URL浏览“ http://something.com/index.asp?search=anything