Top 4 reasons why your javascript is not working in IE7
1. Script tag is on the first line of the page:If you ajax page has javascript in it and the script tag is the first line (or first character of your page), then it is highly likely that IE7 will fail. To overcome this issue, I generally introduce a div tag (I refer it as fake div, because I set its height to 0px)as the first thing on my ajax page.
Solution to problem 1: < style="height: 0px">&nbsq;< /div >
2. Comma after the last element of an array:
Often jquery plugins can take arguements in the form of an array. However, make sure that you do not introduce a comma after last element. Firefox can handle it, but not IE. I believe the reason is that comma indicate that there is another element that will be following it. Thus IE expects that more elements are still coming and wait for them. So
This is wrong | This is right |
{ name: 'Jack', message: 'hello', } | { name: 'Jack', message: 'hello'} |
3. using firebug and console command
Many times developers use Firebug, a Firefox addon. I often use "console" command to debug my scripts in firefox. However, if by chance you left any console command within javascript script, it will break your javascript in IE7. Make sure to comment out or remove all "console" command before you test your javascript in IE7.
4. Trying to access non-exisitng key
if the javascript tries to access non-existing element, it will break your web site in IE7. Firefox will work without raising or reporting any error or warning.
No comments:
Post a Comment