开发者

Getting the url in address bar in an iframe

I am working on a project in drupal in which i have an iframe loaded in another website.

I need to get the url from the address bar.

e.g., lets say i have a website embedded in the 开发者_运维问答iframe as example.com...and another site embedding this iframe has the domain as abcd.com

So, the url that gets formed on accessing any content in the iframe would be like.. abcd.com/#/

I need to get this URL in the iframe.

Please help me resolving this problem. I am tryin to write a custom module for this but dunno how to proceed.


You cannot access the URL of an iframe from the outside. Think about potential XSS attacks that could occur from that:

http://yourbankingsite/account?sessid=2239872379092FEAACC2390823

Of course, this is a bad way to store the session id, but there are quite a few (and popular) sites that do this. If you had access to the iframe URL, a malicious website could be nothing but said iframe and a script to harvest the session ID.


In your iframe you could add a variable to the iframe url and use drupal 'current_path' to get the url of the iframe's parent. Then you could retrieve this variable from your iframe page(and make sure you validate it before you use it). i.e.

www.iframsite.com/iframepage?from=<?php print current_path(); ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜