Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Doctype problem when using Firefox - look at my example
Old 02-03-2007, 04:42 PM Doctype problem when using Firefox - look at my example
Experienced Talker

Posts: 33
Trades: 0
Hi there

I am attempting to make a DIV resize automatically using Javascript.
I have written the code and it works in IE7, but not in Firefox.
Removing the Doctype enables it to run in FF.
I validated the code and it passed.

Here it is in action: http://www.realbabyguide.co.uk/div%20heights.html

Any ideas which Doctype to use. I have tried every one!
Thanks

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html>
<head>
<title>A Test</title>
<style type="text/css">
 body
 {
 background-color:#00CCFF;
 }
 
 .outer
 {
 font-size: 16px;
 background-color:#00CC00;
 padding: 10px;
 width: 100%;
 border-width: 1px;
 border-style: solid;
 border-color: #cc0000;
 }
 #inner
 {
 font-size: 16px;
 background-color:#CC6633;
 padding: 10px;
 width: 50%;
 border-width: 1px;
 border-style: solid;
 border-color: #cc0000;
 }
 
</style>
 
</head>
<body>
<script language="javascript" type="text/javascript">
function getOff()
{
 x = document.getElementById('inner');
 return x.offsetHeight;
 }
function changeOff(amount)
{
 amount = 600-getOff();
 var y = getOff();
 x.style.height = y + amount;
}
</script>
 
<div class="outer">
 <div id="inner">
 
   <h1>This script resizes my "inner" DIV height to 600px - the current height.</h1>
 
   <p>However, although it works in IE7 (haven't tried other IE versions), it will not work in Firefox (2.0.0.1).<br />
   Removing the Doctype enables it to work in Firefox, but screws up IE7 as it renders the page in Quirks mode.<br />
   The page    
   <a href="<A href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.realbabyguide.co.uk%2Fdiv%2520heights.html">validates.</a">http://validator.w3.org/check?uri=http%3A%2F%2Fwww.realbabyguide.co.uk%2Fdiv%2520heights.html">validates.</a>
   </a> 
   <br />
   Any ideas? 
   </p>
 
 </div><!-- Close inner DIV -->
 
</div><!-- Close outer DIV -->
<a href="javascript:changeOff()">Click here and the DIV should resize</a>
</body>
</html>
monkey64 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-03-2007, 05:21 PM Re: Doctype problem when using Firefox - look at my example
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
I suspect it has more to do with your script than the DTD, FF has no problems with DTD's that I'm aware of.
I use:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

I guess I don't see the point in the script anyway. What are you trying to achieve with it ??

There is a JS height adjustment script that does work:
http://www.ampsoft.net/webdesign-l/m...to-bottom.html
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 02-04-2007, 03:28 PM Re: Doctype problem when using Firefox - look at my example
Banned

Posts: 905
Name: Travel Agent
Trades: 0
Quote:
Originally Posted by LadynRed View Post
I guess I don't see the point in the script anyway. What are you trying to achieve with it ??
I agree - doesn't make logical sense.
travelagent is offline
Reply With Quote
View Public Profile
 
Old 02-04-2007, 05:22 PM Re: Doctype problem when using Firefox - look at my example
Skilled Talker

Posts: 96
Name: Tudor Barbu
Trades: 0
monkey64: Try it this way:
Quote:
function changeOff(amount) {
amount = 600-getOff();
var y = getOff();
x = document.getElementById( 'inner' );
x.style.height = y + amount;
}
LadynRed & travelagent: Missing doctype triggers Firefox in quirks mode, and faulty - IE style - scripts may work.
__________________

Please login or register to view this content. Registration is FREE
Tudor.b is offline
Reply With Quote
View Public Profile Visit Tudor.b's homepage!
 
Old 02-05-2007, 11:30 AM Re: Doctype problem when using Firefox - look at my example
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
My point was that having a VALID DOCTYPE does not usually have adverse effects in FF. We all know not having one results in quirks mode.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Doctype problem when using Firefox - look at my example
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45283 seconds with 12 queries