Go To Content
codylindley.com

codylindley.com

The Iframe Slide

With my back against the wall I will occasionally pull out the HTML iframe element and use it in a less than desirable way. For instance, say you need to acquire a section (not the entire page) of content on another domain. Like for instance, the Yahoo.com search box located at the top of the yahoo homepage.

With a bit of CSS trickery, it’s actually possible to isolate a specific region of the page that is being loading into the iframe. In a nut shell, you can place the iframe (positioned absolute) in a div element (position relative) and by using the div as a view box slide the iframe around to perfectly fit the view port. Did that make sense? Essentially the iframe can be given a negative left and top position in order to fix a particular x and y coordinate on the iframed page. Once you have position this coordinate, you then size the outer div to crop the view port down to the exact size of the content you are trying to extract from the iframed site.

Maybe an example would help explain. Check out the yahoo search box on my domain, using an iframe to isolate just the section of the yahoo homepage I want (the search box).

 
  1.   #1 Comment Posted by Nathan Smith on Nov 10, 10:17 AM

    You dirty content leecher. Nice writeup and sweet implementation. Now I shall claim all of CNN as my own! Mua Ha ha!

  2.   #2 Author Comment on Nov 10, 10:19 AM

    @Nate – With knowledge comes great responsibility.

  3.   #3 Comment Posted by Nathan Logan on Nov 14, 12:45 PM

    I can’t wait to pull this article into my site and claim it as my own using this technique. Thanks!

    Seriously, though – this is cool and you’re smart.

  4.   #4 Author Comment on Nov 15, 07:16 AM

    @Nate – Let’s no go overboard.