Posts Tagged ‘Javascript’

7 things you may no know about me.

Sunday, January 3rd, 2010
  • I like to explore. I explore almost anything. For example I explore Karl Marx. Same way I like to learn new things. For example, I learn how to eat by chopstick, memorize values of first few inverse of primes (1/2,1/3,1/5,1/7,….)
  • I always sleep late night. There was time when I used to miss sunrise scene. Now I often miss sunset!!
  • I don’t take any soft drinks. Mineral water is okay. Also no street food.
  • Late night Moon or night sky with full of stars is one of my likings. I like stars a lot.
  • I like traveling a lot. For me, traveling is not only watching, rather its more like feeling. I always try to find the beauty from the place where I travel. It may not have such things. But I’ll find it out. For this, I’ll go there in different seasons, different weathers.
  • If shell script and JavaScript were compiled programming language, I would have told these twos are my most favorite language. But they are scripting language. So I add C (not C++) in the list.
  • I am real industrious. Normally I go slow. But steady. I try to prepare for the worst case. There is no place for plans. Its all about game plans.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Ping.fm Post to StumbleUpon

Internet Explorer : ”Operation aborted” Solution

Saturday, January 26th, 2008

If you ever worked with heavy JS codes or complex DHTML you may have already faced this error. This is like a nightmare. You are opening your web page. IE is loading the site. You see the progress bar. Suddenly you see a message “Internet Explorer cannot open the Internet site http://<Web site>.com. Operation aborted”. The dialog has only one button. so you press it. Then it shows “Page cannot be displayed”. You cannot even debug it. Cause you don’t see any source code. I searched many sites and forums. No one can say anything appropriately. See the MSDN site. They have some tips to avoid it. I don’t know how to reproduce it. But I’ll tell you a solution that worked for me. This solution works for me for jQuery javascript library.

In jQuery most initial operations are writen in domready block. That is,

jQuery(document).ready(

function(){

my_blah_blah_code();

}

);

The function there my_blah_blah_code() runs when DOM is ready. It means when all the elements is loaded in browser and its safe to manipulate it .

But I have seen its really not safe to manipulate it if we use the function jQuery(document).ready() block. You’ll say “No, its working for me”. Well then your lucky that its working. DOM also gives you a attribute in ‘body’ element. The ‘onload’ attribute. It always works. I never see it fails. Both ‘jQuery(document).ready()’ and ‘onload’ attribute gives the same functionality. But they are not same. To test it run a code like the following.

&amp;lt;script src="/path/to/jquery" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;

jQuery(document).ready(

function(){

alert("jQuery domready fires");

}

);

&amp;lt;/script&amp;gt;

You’ll see which alerts later. Its the browser. See the live example here. So its safer to use ‘onload’. Thats why I am using here only ‘onload’. No jQuery(document).ready() block. I am replacing the jQuery ready block by this,

<html>
<head>
<script type="text/javascript" src="/path/to/jquery"></script>
<script type="text/javascript">
function by_blah_blah_code(){
// Write all your initialization code here.
}
</script>
<body>
<script type ="text/javascript" >
if(document.body){
 if(document.all){
 document.body.onload = by_blah_blah_code;
 }else{
 document.body.setAttribute("onload","by_blah_blah_code()");
 }
}else{
 alert("This code must be included after the body tag ;) ");
}
</script>
</body>
</html>

If you use it that way. You wont see any “operation aborted” error.

Best of luck.

© 2008 by A K M Mokaddim

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Ping.fm Post to StumbleUpon