...

View Full Version : DIV Widths and DOCTYPE



jfreak53
12-19-2010, 01:23 PM
So I didn't know whether to put this in HTML & CSS or here. So I'm just going to put it here and the mods can move it if needed.

So I had this script working for auto width of a DIV, then I added DOCTYPE to the top of my document, now it won't change the width ha ha. I have tried with all DOCTYPE's and same thing.

The JS I am using is:


window.onload=function(){
document.getElementById("right").style.width= + screen.width - 193;
}

As I said this worked before I added DOCTYPE to the top of the HTML. But when I add any one of the DOCTYPES it stops working.

Any ideas?

DJCMBear
12-19-2010, 02:57 PM
Try this.



window.onload = (function(){
var right = document.getElementById("right");
if(right) {
right.style.width = (screen.width - 193);
}
});

abduraooft
12-19-2010, 02:59 PM
Not sure, but don't you need the units, px, there?

DJCMBear
12-19-2010, 03:04 PM
Not sure, but don;t you need the units, px, there?

In css you can just write the number without the units which I don't personally do although it can be done, now with javascript im not 100% sure about needing the units but im guessing as it's using styling commands that it would be the same as the css parser.

jfreak53
12-20-2010, 01:12 PM
Hey, we're good now. It was the pixels, didn't even think about it since it was working before that. But I guess it makes sense since I was assigning a DOCTYPE to it, the CSS had to be prefect.

More of a CSS thing than a javascript thing, Thanks guys.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum