By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Doctype is breaking my iframe in mozilla

P: 8
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):
http://ww-chat.com/games.php

This is the page without a doctype (Works properly only on FIREFOX - not IE):
http://ww-chat.com/games-nodoctype.php


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:
http://ww-chat.com/iframeresize.js


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

Thanks,
Worldwideebm
Sep 28 '09 #1
Share this Question
Share on Google+
10 Replies


P: 8
Can anyone help me on this problem?
Oct 1 '09 #2

acoder
Expert Mod 15k+
P: 16,027
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

P: 8
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

Dormilich
Expert Mod 5K+
P: 8,639
@worldwideebm
every numerical value (except 0) requires a unit in CSS.
Oct 1 '09 #5

P: 8
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){
try{
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 10px;
}
catch(err){
window.status = err.message;
}
}

Any ideas why it wouldn't work?
Oct 1 '09 #6

Plater
Expert 5K+
P: 7,872
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; 
  6.  
Expand|Select|Wrap|Line Numbers
  1. Error: initMenu is not defined
  2. Source File: http://ww-chat.com/games-nodoctype.php
  3. Line: 3
  4.  
Try doing this:
objToResize.height = (innerDoc.body.scrollHeight + 10)+"px";
Oct 1 '09 #7

P: 8
THANK YOU SO MUCH!
That worked! =]

Thanks to every who replied =]
Oct 1 '09 #8

Plater
Expert 5K+
P: 7,872
Now both your links work in IE and FF.
All fixed?
Oct 1 '09 #9

P: 8
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

drhowarddrfine
Expert 5K+
P: 7,435
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.