"IE Sucks" Series continued – #2

IE Ajax problem “Could not complete operation c00ce56e”.
This error appears in the stupid IE when you don't set your server response character encoding to “UTF-8”.
This ugly behavior is M$ IE copyrighted, I really didn't find in any other modern browsers like (FF, Opera).

To solve this problem :
Set your Servlet or JSP response type to UTF-8 as follows:

response.setCharacterEncoding("UTF-8");

"IE Sucks" Series continued

Last days, I was developing a pure Ajax JS component from scratch that should work cross browsers, I really found nightmares during my way because of the ugly bad stupid IE.

One of the bad IE stupid features that really suck is the IE Ajax Caching.

UnLike FF, If you are trying to send simple Ajax GET requests to your server servlet, you will find the stupid IE returns stale old request data.

After spending one hour in investigation, I found the way that got me out of this hole.

To solve this problem you should add a random dummy parameter to your GET url request to force IE to refresh itself.

For example)

var url = "/RichTextEditorWorld/ImageUploaderServlet?ieDummyStupidParameter=" + new Date().getTime();

DOM setAttribute() is different in M$ IE "the crappy"

Last days, I was working on a pure heavy (JavaScript/Ajax) component.
The component was required to run correctly across different browsers.
I really did the job in few hours but after start testing the component, I found it works fine on both FF and Opera but as usual I found the M$ IE complaining. I really found alot of IE weird things.

For example, if we try the following code in FF or even Opera, it would work fine.

<html>

<div id="myDiv">
</div>

<input value="Add New Element to div" type="button"
onclick="createNewElement();" />

<script>
function createNewElement() {
   var parentDiv = document.getElementById("myDiv");
   var buttonElement = document.createElement("input");

   buttonElement.setAttribute("type", "button");
   buttonElement.setAttribute("id", "myButton");
   buttonElement.setAttribute("value", "New Button");
   buttonElement.setAttribute("onMouseDown", "alert('Hi');");

   parentDiv.appendChild(buttonElement);
}
</script>

</html>

The “New Button” button would be created if we click on the “Add New Element to div” button.
The 'Hi' message would appear also if we click on the “New Button” button. Here is the output :



But if we try to run the previous code on the M$ IE, we will find the code written under the “onMouseDown” doesn't work.
After spending some time in investigation, I found that the M$ crappy browser doesn't support setAttribute onEventXXX.
Here is the IE output (Nothing is done after clicking on the “New Button” button :





Finally after spending some time with the ugly IE, I could fix this problem by doing the following:

// The IE Fix.
buttonElement.onmousedown = function() {
     alert("Hi - Fixed on the crappy IE");
};

Why IE is idiotic and Stupid?

Very simple.
Just try to run this JavaScript code in IE7 and FireFox :-

<script>
    function processString(myString) {
      for (i = 0; i < myString.length; ++i) {
          alert(myString[i]);
      }
    }
    processString("IESucks");
</script>

This code runs correctly on FireFox.
but in IE7 the result will be 'undefined' :D.

Conclusion :
IE doesnot support the string [] operator so u have to use charAt( ).
IE really sucks :).