<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Mehfuz's WebLog : IE8</title><link>http://weblogs.asp.net/mehfuzh/archive/tags/IE8/default.aspx</link><description>Tags: IE8</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>IE8 from MIX08 to developers</title><link>http://weblogs.asp.net/mehfuzh/archive/2008/03/09/ie8-from-mix08-to-developers.aspx</link><pubDate>Sat, 08 Mar 2008 18:55:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5939438</guid><dc:creator>mehfuzh</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/mehfuzh/rsscomments.aspx?PostID=5939438</wfw:commentRss><comments>http://weblogs.asp.net/mehfuzh/archive/2008/03/09/ie8-from-mix08-to-developers.aspx#comments</comments><description>&lt;p&gt;Although I was not in mix08, I took interest in knowing every detail of how it is going on and downloaded the sessions and keynote as it is available at &lt;a href="http://sesssions.visitmix.com"&gt;http://sesssions.visitmix.com&lt;/a&gt; , a clean Silverlight site with all the cool videos. This morning , I was watching out the keynote, and found Dean Hachamovitch (General manager,IE)&amp;nbsp; point out some of the cool new features that really dropped my jaws.&lt;/p&gt; &lt;p&gt;Apart with the new W3C compliance and CSS 2.1 along with HTML 5, two things that really amazed me are (which I will be describing shortly)&lt;/p&gt; &lt;ol&gt; &lt;ol&gt; &lt;li&gt;Ajax Navigation  &lt;li&gt;Connectivity Events.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt; &lt;p&gt;Firstly, in order to use all the IE8 and HTML 5 features, we need to declare a doc type on top of our HTML file that looks like &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="html"&gt;DOCTYPE&lt;/span&gt; &lt;span class="attr"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This is the doc type of HTML 5, without using this doc type it is also possible to test your IE8 compatible script and for that SHIFT + F12 hotkey should be pressed, which will bring up the "Developer Tools" console, there from the View menu , you have to specify the compatibility mode to IE8 and hit F5 on your browser to see the effect :-)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/IE8todevelopers_2644/image_2.png"&gt;&lt;img alt="image" src="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/IE8todevelopers_2644/image_thumb.png" width="500" height="136"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now, Let's start with simple but cool one called "Connectivity Events". It often happens that I am writing a big comment in someone's blog by the time ISP goes down or page expired, and to my frustration I write it again anyhow. But in IE8 you can let users save their data in case of anomalies by using the &lt;em&gt;window.navigator.onLine&lt;/em&gt; property.Using this,&amp;nbsp; you can check out if you lost your connectivity with the server and show your user with proper message, rather make him redo things again.This is pretty simple and I fused out a demo script which does right that.&lt;/p&gt;
&lt;p&gt;I declared a DIV block that contains the message , when there is no connection.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="offlineDiv"&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="color:Red;font-size:14pt;display:none;"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
Connection Status: offline
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;And another DIV block , that is visible when you are online.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="onlineDiv"&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="color:Green;font-size:14pt;display:block;"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
Connection Status: online
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;And I wrote a sample script that uses the &lt;em&gt;window.navigator.onLine&lt;/em&gt; , to check it out and put it in the head tag. The JS actually toggles the div on and off depending on the connection status.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;function&lt;/span&gt; check()
{
 &lt;span class="kwrd"&gt;var&lt;/span&gt; online = window.navigator.onLine;
 
 &lt;span class="kwrd"&gt;if&lt;/span&gt; (!online) 
 {
   document.getElementById(&lt;span class="str"&gt;'offlineDiv'&lt;/span&gt;).style.display = &lt;span class="str"&gt;"block"&lt;/span&gt;;
   document.getElementById(&lt;span class="str"&gt;'onlineDiv'&lt;/span&gt;).style.display = &lt;span class="str"&gt;"none"&lt;/span&gt;;
 }
 &lt;span class="kwrd"&gt;else&lt;/span&gt;
 {
   document.getElementById(&lt;span class="str"&gt;'offlineDiv'&lt;/span&gt;).style.display = &lt;span class="str"&gt;"none"&lt;/span&gt;;
   document.getElementById(&lt;span class="str"&gt;'onlineDiv'&lt;/span&gt;).style.display = &lt;span class="str"&gt;"block"&lt;/span&gt;;
 }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now, either I can execute this JS in body &lt;em&gt;onload&lt;/em&gt; event or at the end of the function&amp;nbsp; or I can further use the &lt;em&gt;ononline&lt;/em&gt;&amp;nbsp; and onoffline event in the body tag. Either way it will produce the same result.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt; &lt;span class="attr"&gt;ononline&lt;/span&gt;&lt;span class="kwrd"&gt;="check()"&lt;/span&gt; &lt;span class="attr"&gt;onoffline&lt;/span&gt;&lt;span class="kwrd"&gt;="check()"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;...&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class="html"&gt;&lt;span class="kwrd"&gt;You can see the online/offline status by checking/unchecking the tools-&amp;gt;work offline or plugging on/off your Internet :-)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;Moving to the another feature called&amp;nbsp; "Ajax Navigation". We all know that browser back does not work properly with Ajax apps, you can read it further at MSDN, but I will do show the pointer to use it for making your app taking the advantage of it. The magic is done by a simple but a mighty &lt;em&gt;window.location.hash&lt;/em&gt; property. Now, it is possible to set hash for pre IE8 browsers as well, but what makes it special is that the browser creates a history entry for the changed hash URL by which we can go back to the wizard step or map location by pressing the browser back in our favorite Ajax app.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;But just going back and forth does not solve the problem , as we need to reproduce the step depending on the hash value and for that we need to trigger the appropriate function , when hash is changed. IE8 takes it further by introducing a window event called &lt;em&gt;onhashchange.&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;window.onhashchange = &lt;span class="kwrd"&gt;function&lt;/span&gt;() { // your code goes here; }&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&lt;span class="kwrd"&gt;This can be placed anywhere in the "Head" of your html doc. I have created a script file with step 1, 2 and 3 using some DIV and text, go to different steps and press browser back to see the effect, both this and the other script is added &lt;a href="http://weblogs.asp.net/blogs/mehfuzh/ie8_demo_scripts.zip"&gt;here (To Download)&lt;/a&gt; for you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;Finally, to try these and many more&amp;nbsp; grab a copy of IE8 Beta from MSDN download center and make your app ready for IE8 today :-).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;Updated on March 19, 2008&lt;/span&gt;&lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.asp.net%2fmehfuzh%2farchive%2f2008%2f03%2f09%2fie8-from-mix08-to-developers.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.asp.net%2fmehfuzh%2farchive%2f2008%2f03%2f09%2fie8-from-mix08-to-developers.aspx"&gt;&lt;/a&gt; 
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5939438" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/mehfuzh/archive/tags/Javascript/default.aspx">Javascript</category><category domain="http://weblogs.asp.net/mehfuzh/archive/tags/IE8/default.aspx">IE8</category></item></channel></rss>