471,854 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 software developers and data experts.

Doctype is breaking my iframe in mozilla

This is a problem that i have googled for hours and can't find an answer so i resort to asking on here because i found similar question on here.

I have a page i use, It has an iframe on it but it is not regular iframe, The iframe has a resizing script that resizes the height of the iframe to the height of the page being viewed. Using this script it eliminates scrolling!

This has all been working out great but then i realise for it to function properly in IE i need to add a doctype, When i add a doctype to it it functions properly in IE but it doesn't work in firefox. In firefox the frame doesnt resize and it is like 50px height.
I have tried a bunch of different doctypes and they don't work.

This is the problem page (with doctype - works properly only on IE):

This is the page without a doctype (Works properly only on FIREFOX - not IE):

This is the code that i use for the iframe:

<iframe id="games" name="games" src="http://ww-chat.com/games/" frameborder=0 scrolling=no width="990" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('games');}"></iframe>

This is the script that it uses to resize the frame:

I have other iframes on my website which don't use the resize script and they work perfectly fine (with doctype!).

Sep 28 '09 #1
10 3124
Can anyone help me on this problem?
Oct 1 '09 #2
16,027 Expert Mod 8TB
You should look at getting rid of these errors.

Anyhow, the problem seems to be because you've forgotten the units when setting the height. Add "px" to the height setting.
Oct 1 '09 #3
Hey, I'm not very good at this but where exactly should I put px?

I have tried placing it after 990 (the width) and i have tried placing px after 10 (in the script) and neither of those fixed it.

Any ideas?

Btw the resize script isn't mine..
Oct 1 '09 #4
8,658 Expert Mod 8TB
every numerical value (except 0) requires a unit in CSS.
Oct 1 '09 #5
I have tried putting px after both numbers and it doesn't fix. I don't know what could cause this, it only happens when i put the doctype in (because it wont work in IE without doctype, but the height doesn't work in firefox if i use doctype) I don't use CSS for anything on the iframe so it can't be css.

Here is what my iframe page is:

<iframe id="games" name="games" src="http://ww-chat.com/games/" frameborder=0 scrolling=no width="990px" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('games');}"><p>Your browser does not support Iframes, People upgrade to a compatible browser.</p></iframe>
Here is the script that resizes my iframe:
function autoIframe(frameId){
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 10px;
window.status = err.message;

Any ideas why it wouldn't work?
Oct 1 '09 #6
7,872 Expert 4TB
Neither of those two links in the first post worked for me in IE or in FF.
Your javascript has errors.
Expand|Select|Wrap|Line Numbers
  1. Error: missing ; before statement
  2. Source File: http://ww-chat.com/iframeresize.js
  3. Line: 6, Column: 50
  4. Source Code:
  5. objToResize.height = innerDoc.body.scrollHeight + 10px; 
Expand|Select|Wrap|Line Numbers
  1. Error: initMenu is not defined
  2. Source File: http://ww-chat.com/games-nodoctype.php
  3. Line: 3
Try doing this:
objToResize.height = (innerDoc.body.scrollHeight + 10)+"px";
Oct 1 '09 #7
That worked! =]

Thanks to every who replied =]
Oct 1 '09 #8
7,872 Expert 4TB
Now both your links work in IE and FF.
All fixed?
Oct 1 '09 #9
Yes =]

But there is another problem.. But i might start a new thread for it?

I don't think that it is related to this problem..
Oct 1 '09 #10
7,435 Expert 4TB
It should be noted that you will never get IE to attempt to perform like the other more modern browsers without a proper doctype. ALL new web pages are required to have one.
Oct 2 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jeff Thies | last post: by
3 posts views Thread by alejandro.rivero | last post: by
6 posts views Thread by Patrick | last post: by
6 posts views Thread by Randell D. | last post: by
16 posts views Thread by Mcginkel | last post: by
22 posts views Thread by stevenkobes | last post: by
14 posts views Thread by Aaron Gray | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.