The More You Know » 2007 » July

It is possible in IE for DOM manipulation during load to cause an error that looks like the following

 IE "Internet Explorer cannot open the Internet site" ... "Operation aborted"

This error is directly cause by script called with in an element that attempts to append/insert DOM nodes to its unclosed parent’s parent node. For example the following code will work fine in FireFox and Opera, but not in IE.

<html>

 <head>

 	<title>Test</title>

 </head>

 <body>

 	<div id="div0" style="width:150px;border:1px solid black;margin:25px;">Test Div 0</div>

 	<div id="div1" style="width:200px;border:1px solid red">

 		Test Div 1

 		<div>

 			<script type="text/javascript">

 				var div0 = document.getElementById( "div0" );

 				var div1 = document.getElementById( "div1" );

 				var aDiv = document.createElement( "DIV" );

 				aDiv.appendChild( document.createTextNode( "aDiv" ) );

 				div1.appendChild( aDiv );

 			</script>

 		</div>

 		<div id="div2" style="border:1px solid green">Test Div 2</div>

 	</div>

 </body>

</html>

If the div in the example above that cotains the script block is removed, the code will run just fine in IE.

<html>

 <head>

 	<title>Test</title>

 </head>

 <body>

 	<div id="div0" style="width:150px;border:1px solid black;margin:25px;">Test Div 0</div>

 	<div id="div1" style="width:200px;border:1px solid red">

 		Test Div 1

 		<script type="text/javascript">

 			var div0 = document.getElementById( "div0" );

 			var div1 = document.getElementById( "div1" );

 			var aDiv = document.createElement( "DIV" );

 			aDiv.appendChild( document.createTextNode( "aDiv" ) );

 			div1.appendChild( aDiv );

 		</script>

 		<div id="div2" style="border:1px solid green">Test Div 2</div>

 	</div>

 </body>

</html>

This is known behaviour and is to be expected. It just is one of those bugs that frustrates new JavaScript developers.

The solution is quite simple and it is either to put the script block on the first child level, run post load (load or DOM content load), or to put the script block after the close of the appended to item.

Everyone knows that pirates are awesome. The popularity of the recent Pirates of Caribbean movies staring Johnny Depp prove that fact. However, there is a juicy piece of pirate speech that everyone has said at one point in time, “Shiver me timbers.” It is usually said in shock and most people know the right situations to use it. However, the meaning of it is not always known or easily searchable.

There is one sight that I came across through an article on AllExperts.com. The article pointed to The Pirates Realm. They have little section title “Pirate Talk” which describes the phrase as follows:

akin to "Blow me down!", an expression of shock or disbelief, believed to come from the sound the ship made when 'shocked' by running aground or hit by a cannon blast.

This definition is popularly believed mostly because of the word “shiver” being literally defined as our verb “to shiver.”. You can see examples of this on Urban Dictionary and other sites. However, during the days of Pirates a shive/shiver, as in the noun, was a piece or splinter of wood. To shiver, meant to splinter a piece of wood into smaller pieces. Thus “shiver me timbers” mean to split a mast into splinters. Since pirate ships were all wind powered, when a mast (or timber) was shivered (or destroyed), the pirates were as good as dead. They were left on the seas without any way to move the ship or call for help.

For corporate users, your company may or may not enforce a start page that you do not agree with. Be it company news or a slow loading flash application that makes your slow corporate laptop cry in pain. For some, just changing the start page in the IE properties dialogue is enough. However, for those who have it reset on them whenever they logon/startup, it is an annoyance.

There are many solutions to this problem. The most elegant using startup scripts that just set the value each time. Another would be to use FireFox, but too many companies do not even allow that (mine does!). Also, if you are an unprivileged user these solutions may not be available to you. What you can do is create a new shortcut that forces your home page.

  • Find the IE executable (C:\Program Files\Internet Explorer\IEXPLORE.EXE). If you run into permission problems right click and drag to a directory where you have write permissions. Upon releasing the right button, chose create shortcut.
  • Right click it and choose Create Shortcut.
  • Copy the short cut to wherever you want to use it and possibly rename it.
  • Right click the shortcut and choose properties
  • You should see the line: “C:\Program Files\Internet Explorer\IEXPLORE.EXE”
  • Change that to “C:\Program Files\Internet Explorer\IEXPLORE.EXE” http://www.myFavoriteSite.com
      Another alternative is: “C:\Program Files\Internet Explorer\IEXPLORE.EXE” about:blank
      Which is what I prefer as it is has zero load time and lets me choose where I want to spend my load time. Go saving 3 seconds!