toxicious Posted May 5, 2012 Share Posted May 5, 2012 Everything worked perfectly everywhere, except for in IE. I found out that I needed a DOCTYPE declaration at top to make the page show correctly in IE. So I added this one: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Now the page looks as it should in all browsers, except for one thing, that line of code broke my javascript resize of some divs at page load?!I have hooked the jquery window.load function to resize 2 divs at the page, but it doesn't work anymore. If I remove the DOCTYPE it works again. So I figured there must be something "invalid" in my resize code, which is this one: function resize(){ var pageWidth = document.body.offsetWidth;var middleWidth = 530;var sideWidth = (pageWidth - middleWidth) / 2;document.getElementById("leftCol").style.width = sideWidth;document.getElementById("rightCol").style.width = sideWidth;} In the error console it says that "document.getElementById("leftCol") is null". Why can't I use getElementById anymore? Link to comment Share on other sites More sharing options...
Ingolme Posted May 5, 2012 Share Posted May 5, 2012 It might be due to case sensitivity. Check that your element's ID is "leftCol" and not "leftcol" or something else. Also, be sure the element has an "id" attribute and not a "name" attribute. The DOCTYPE only breaks the page if something was wrong in it to begin with. Link to comment Share on other sites More sharing options...
toxicious Posted May 5, 2012 Author Share Posted May 5, 2012 Nope no writing errors. I was able to get it working again by doing my resize via jQuery, $('#leftCol').css('width', sideWidth);So I'll stick to that instead. But still weird that the original thingy doesn't work... Link to comment Share on other sites More sharing options...
Ingolme Posted May 5, 2012 Share Posted May 5, 2012 If you could show a working example of the problem then I could see the problem. Link to comment Share on other sites More sharing options...
Don E Posted May 5, 2012 Share Posted May 5, 2012 I'm not entirely sure, but depending on what IE your checking the results with, if it's ie8, then it may be because of what's described here: http://yyosifov.blogspot.com/2009/03/getelementbyid-compared-in-ie6-ie7-and.html Maybe not, but I'd thought post this because I came across a similar problem not too long ago and the site helped me understand what was going on. Link to comment Share on other sites More sharing options...
toxicious Posted May 5, 2012 Author Share Posted May 5, 2012 (edited) I'm not entirely sure, but depending on what IE your checking the results with, if it's ie8, then it may be because of what's described here: http://yyosifov.blog...e6-ie7-and.html Maybe not, but I'd thought post this because I came across a similar problem not too long ago and the site helped me understand what was going on. Thanks for the tip, but I tested it in IE, Chrome and Firefox, so nope, not because of that. Edited May 5, 2012 by toxicious Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now