DelphiFAQ Home Search:
General :: Web publishing :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

HTML Content invisible in IE, but properly shown in Firefox

Recently I added some javascript to this web site and tested it in FireFox. Everything worked fine. Then I got emails that the comments were no longer visible. I tested, and could not confirm the problem. Today at a friend's house, I encountered the same problem. Comments were invisible on all pages if you used Internet Explorer. They would show fine in Firefox!

Here are some thoughts I had:

  • invalid Google Adsense code
  • run the HTML validator (it validated my page as 100% conform)
  • compare the HTML presented to IE with the HTML presented to FireFox (it was identical)

Eventually I found the reason for the problem.
See the code segment below. It causes text XXX to be rendered in FireFox but IE would not show it (it would treat it as a comment!)

The W3 HTML validator would not catch this as a bug!

Look at the bolded section - you can see that I forgot the matching closing part. FireFox would ignore this problem and recognize the end of the javascript by the /script tag. IE would ignore everything up to the //--> tag.

<script language=javascript>
 <!--
 alert('blah');
 </script>
 
 XXX
 
 <script>
 alert('blah2');
 //-->
 </script>
 
 yyy

Generated 12:02:08 on Sep 19, 2017