Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gracefully closing a frame (toolbar) around an iframe

I've created a tool that is used with a fairly popular music retailer.

The tool provides an enhanced search feature (transparent last.fm results, no ads, no lameness, nothing creepy) and I've found the most useful and unobtrusive way to display the search is as a toolbar using the much maligned iframe. This allows users to load search without stealing the users focus.

Not being a particularly big fan of iframes I thought it would be trivial to add a “close this frame” (ala Google image search) link allowing users to quickly and easily regain control of their browser.

However unlike google, I doen't know what the location of the content in the iframe is (only where it started, via src).

So now I find myself in world of XSS and all the security related concerns.

Using Javascript I've added 'back' and 'forward' buttons with the history object called from links in the parent (when a user does a search the results load into the iframe, so the back button allows them to go back to the primary site after their done using/perusing the search results).

Is there any way to call the current location within the iframe and reload the page (now sans frames) to that location?

I've checked PHP $GLOBAL/$_SERVER variables to see I might get lucky. I understand that there are security concerns, but I don't see how this particular function would be any different then history.back() where the browser makes the call itself without 'notifying' my parent frame.

I know I can retrieve the src location from the iframe itself, but of course that presumes the user doesn't navigate beyond this page, and if they do they don't mind losing their current location and being redirected back to page called initially by the frame (...ah...).

It almost seems like frames are designed to steal windows with no means for gracefully 'breaking out' and preserving integrity of the users session.

No wonder people hate them. :)

like image 313
user22802 Avatar asked Nov 06 '22 23:11

user22802


1 Answers

On Google image search when you remove the frame it functions as you currently propose, by returning to the original frame source. For XSS reasons, finding the current location shouldn't be possible, and if it was it would be considered a bug and fixed in subsequent browser patches, so it might not be best to rely on such a quirk if one existed. A way to elegantly break out without revealing location would be nice, though. This might be something you can propose to the HTML5 group.

like image 197
Zach Avatar answered Nov 12 '22 13:11

Zach