Javascript implemented iFrame has extended bottom how do I hide it?

Posted on 2009-04-08
Medium Priority
Last Modified: 2012-05-06

Popular question on positioning content exactly within iframe and I have only found one true solution however I can't perfect its use.

Code Below.

You should be able to quickly test it yourself and see that my example is a flash game which is boxed off nicely HOWEVER. If you put a div below the iframe it ends up about 500 pixels lower creating a large empty space. Its obvious what setting creates the exact height however when I change it from 794 to anything lower it effects the iframe content view. Counter balance has been impossible, maybe something I'm not getting!

Any help on would be great. I know iFrames are to be buried however I don't believe they should be and plan to use them a lot so help is great right now.
<style type="text/css">
				#innerIframe{ position:absolute;
				/* increase to nudge right, decrease to nudge left. Note negative number. */
				/* increase to nudge down, decrease to nudge up. Note negative number. */
				<div id='outerDiv'>
				<iframe id='innerIframe' scrolling=no  src=''>
				<script type='text/javascript'>
				_rect=new Array();
				_rect.push(-220);//site left
				_rect.push(-385);//moved site up
				_rect.push(130);//increase window size to right
				_rect.push(0);//extends or decreases bottom bottom
				_rect.push(622);//changed overall view width
				_rect.push(794);//Changed overall view height

Open in new window

Question by:Ryan Bayne
  • 4
  • 3

Expert Comment

ID: 24103558
Okay, lol... first of all.. please tidy your script, as this is pain to look at ;P
Second.. Have you tested your script in other browsers than IE (or w/e u were using) ?

And I'm not sure what you are trying to do, other than just showing that game on your page, so here's how you show that game on your page, in all browsers, using clean, neat and tidy code ;)

<style type="text/css">
        width: 550px;
        height: 400px;
        border: 10px solid yellow;
<div id="outerDiv">
    <object id="FlashGame" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="550" height="400">
        <param name="movie" value="http://www.yogames.net/flash2/xstuntbike.swf">
        <param name="quality" value="high">
        <embed src="http://www.yogames.net/flash2/xstuntbike.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" class="FlashGame" width="550" height="400">

Open in new window


Author Comment

by:Ryan Bayne
ID: 24105795
Its not actually my script and I normally get it working then tidy so sorry about that.

I need the iFrame working as it is to be used many times. That flash game was just a quick example.

You can see the problem if by testing that script and putting another div or paragraph under all of it. It ends up way down the page. Hope that makes sense.

Expert Comment

ID: 24105874

Okay, so you want an iframe that has a page inside, scrolled to the right position to show a specific area ?
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Author Comment

by:Ryan Bayne
ID: 24116455
Yes, I used to do it easy a long time ago but the usual code did not work and I read its become a bit old with W3C so I figured the browser was not supporting it or something?!

Are you going to tell me I don't need this JS?

Expert Comment

ID: 24119152
Well, while I'll look for your answer, your code in the first post doesn't work in other browsers than IE.
And most browsers exept IE only work according to the W3C rules and standards.

Accepted Solution

Duboux earned 1000 total points
ID: 24119856
Okay, bad news...

JavaScript is restricted to act on pages outside the domain.

But I can´t seem to get a page inside an iframe to scroll anyway, whether it´s a local page in there or not.. Unless the javacommand to scroll (which is scrollBy(xvalue, yvalue), btw) is on the page inside the iframe itself..

So, what you can try to do, and this is a dirty trick, is to make a local php-page inside the frame, that fetches the source code from the page you want to show, and adds the correct javascript command to scroll on load.

Sorry for the bad news..

Author Comment

by:Ryan Bayne
ID: 24121876
Well that changes a lot of my plans for implementing a lot of iFrames in a lot of ways! I was going to display all of my clients websites on 1 page in my admin area for a quick status check on stats and other implementations for handyness.

I'll look into using those standard frames but I aint used them since before uni and I hate them! Thanks for doing that research and coming to a conclusion. Sometimes when I was reading about iFrames I couldnt figure out if people were saying they had a complete solution or PART of a solution or NONE at all!  lol


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question