Differences in Internet Explorer and FireFox CSS and Javascript

I've done quite a few web UI changes, including CSS styles and javascript testing in IE. Now I have to  ensure, that it also work in FioreFox.
The suggested  Collection of Global CSS Reset Styles not always work , if site has already some default style settings.
I also incorrectly used parentElement in DOM - always use parentNode instead.
innerText
Thanks to Damian Edwards who pointed another FireFox incompatibility bug in our javascript code:
The line in javascript causing the issue easily figured out using Firebug.
 The elem.innerText property is an IE proprietary addition and thus not usually supported by other browsers. Instead you should be getting the “inner text” of the cell using something like the following:

elem.firstChild.nodeValue;

This uses W3C DOM compliant properties to retrieve the text value of the first TextNode of the cell. This makes it more likely to work across browsers.

 
Width in IE and Firefox   treated differently.
According to standard (that FireFox follows), content width is set excluding paddings and border(see figure there).
"The size of the box is the sum of the element width (i.e. formatted text or image) and the padding, the border and the margin areas".

But in IE the width of the box is the width of the content plus any border or padding.
In other words:
width(IE)="padding-left"+"border-left"+ width(FF) + "padding-right"+"border--right".
To make IE to follow standard can be done by specifying
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
Unfortunately, this change will have MAJOR impact on existing web site. In our application we effectively have one page with different user controls loaded dynamically, so the change will effect everything -too risky.
Class and ID Names are Case Sensitive in FireFox
IE is not case sensitive, when you search by ID.  If your  script is working in IE, but not if FF, check that the IDs are written consistently.
More tips can be found in Adrian Anttila's post JavaScript differences in Firefox and Internet Explorer  
Different Tools.
For IE I mentioned some tools in my older post Tools to debug/Trace ASP.NET applications.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Wednesday, February 13, 2008 10:54 PM
Print

Comments on this entry:

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by Metroid48 at 12/28/2008 4:40 AM
Gravatar
I just wanted to say thanks, as the doctype line actually fixed a page that was bugging me - it displayed perfectly in firefox but had odd spacing in IE.

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by Cody at 9/8/2009 11:10 AM
Gravatar
I'm having trouble with firefox reading my truncated blog posts (www.artstarblog.com). IE and safari work great.

Firefox will pull the flash from the original posts and put them on the "homepage" in random locations.

Any ideas?

Thanks!
Cody

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by hari krishna adhikri at 1/15/2010 7:37 AM
Gravatar
what is the difference between ie and firefix in the case of css and html
plese give me information about this problem

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by Elena at 10/27/2010 8:52 PM
Gravatar
I have a question. My host is JustHost and built my site with RV Site Builders, all in WYSIWYG. I don't know coding. They did something with Java I believe. Now the site is ruined. In Firefox even the menu is not visible and is 6-inch wide. When I try to put my cursor on the page, sometimes the pages jumps away instead to editing. Everything is a mess - and a different mess in each browsers. However, when I go into HTML source I never get the full HTPM (it's in PhP) and anything I inserted there even if I learn where and what, it does not have any effect. Do you have any idea of what are my options - including if it helps taking my site to another host or what?

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by Business Security Software at 3/5/2011 9:15 AM
Gravatar
Firefox and Mozilla are the biggest internet browsers on the market, with Chrome coming from behind. However, I don`t like IE at all because of many reasons, starting from speed and finishing with internet security. The best things about browsers are that they are free to use and you can choose what to use and which browser suits you best.

# re: Differences in Internet Explorer and FireFox CSS and Javascript

Left by riple at 1/11/2012 10:34 PM
Gravatar
Until today I don't need it for my website but I think for the future I need to apply it to my web.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910