Jump to content


Stop iFrames from Scrolling?


2 replies to this topic

#1 Shogun Bear

    Young Padawan

  • Members
  • Pip
  • 6 posts
  • Gender:Female
  • Location:Wisconsin, USA
  • Interests:Politics; News; Web-design; Photoshop; Art; Music; Writing; History

Posted 03 February 2008 - 12:23 PM



I've always wanted to use iFrames since they save space, I think they look better, etc. but I have continuously run into the same problem. They always scroll, even with the scrolling=no, which I learned only hides the scrollbar. I have a tendency to make layouts that are not meant for scrolling content and this is what I did this time, but I am determined to get iFrames working, one way or another. xD

http://thatspecialsite.com/testingiframes.html (just the testing page)

As you can see, the content is scrolling, but I don't want it to do that. I want it to stretch with the content of the page in the frame rather than scroll it. Is there a way to do this?



Edited by Shogun Bear, 03 February 2008 - 12:25 PM.


#2 pieterjan

    Young Padawan

  • Members
  • Pip
  • 15 posts

Posted 04 February 2008 - 09:06 AM

This is how I do it:

some js (between the head tags):

<script  type="text/javascript">
function pausecomp(millis) {
  var date = new Date();
  var curDate = null;
  do {
	curDate = new Date();
  }
  while(curDate-date < millis);
}
</script>

in your iframe tag you add:

onLoad="this.style.height=0;this.style.height=this.contentWindow.document.body.scrol
lHeight"

I had in the last bit of code also something like pausecomp added. This was needed to make sure it loads properly in Opera but I left it out and it still works. However the JS for pausecomp is still needed (I think) because it still has to load. Well, maybe my explanation about this isn't 100% but this should work.

#3 Shogun Bear

    Young Padawan

  • Members
  • Pip
  • 6 posts
  • Gender:Female
  • Location:Wisconsin, USA
  • Interests:Politics; News; Web-design; Photoshop; Art; Music; Writing; History

Posted 04 February 2008 - 04:20 PM



Thank you! :3 It works on both Internet Explorer and Firefox which is pretty much my main concern, since as far as I know those are the most used (I could be wrong, but everyone I know uses one of those two. xD)

So yeah. P: Thanks a bunch. :angry:








1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users