An iframe containing the Google homepage Did you happen to surf to a site that relies IFRAME to display some content? Apart from the fact that their use is - in my opinion - strongly inadvisable, I often have to do maintenance on old sites that use the Internet to find myself in situations IFRAME and similar to the one I'm about to describe.

  1. I am in a page that shows - in a large vertical IFRAME - a long form to be completed
  2. fill out the form and skim down the page as they compile the fields
  3. I press the submit button that is (as it should be) on the bottom of the page within iframe
  4. at this point, the operation result is shown in a page response which remains in the same IFRAME, but whose incipit - imagining a confirmation page smaller in size - is located outside of the screen: they are thus forced to flow the page up until reaching the response obtained

The solution to this type of problem is simple and consists of inserting an anchor in the top of the page that contains the IFRAME (page mother). For example:

<a name="my_top"></a> This allows us to have a benchmark that can be easily invoked from the page contained the same iframe. The recall is due to the anchor via a simple JavaScript statement that is executed when the page loads response:

<body onload="parent.location.href=parent.location.href+'#my_top'"> Note the call of the parent page (the one that contains the IFRAME) through education javascript `parent`.

Share this content:
  • del.icio.us
  • Google Bookmarks
  • Digg
  • Facebook
  • Technorati
  • MySpace
  • Twitter