INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1846, 3, '2012-04-09 11:54:22', '2012-04-09 15:54:22', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\nStep 1: Declare Standards mode and valid markup for modern browsers\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\nStep 2: Update your CSS vendor prefixes\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\nStep 3: Get rid of browser sniffing methods\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n \r\n\r\nFeature Detection\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\n \r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n \r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n1.	Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.\r\n2.	Select the AutoResponder tab on the right.\r\n3.	Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.\r\n4.	Drag the selected session from the left panel into the AutoResponder tab.\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\nâ—	If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/\r\nâ—	Then respond with: *200-SESSION_3\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\nStep 4: Update touch and pointer events\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n \r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nTesting both experiences\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n1.	Press F12 to reveal the Developer Tools\r\n2.	Change your Document Mode to Internet Explorer 7 Standards\r\n3.	Refresh the page\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\nThat’s all!\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-3', '', '', '2012-04-09 11:54:22', '2012-04-09 15:54:22', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-3/', 0, 'revision', '', 0),
(1847, 3, '2012-04-09 11:54:51', '2012-04-09 15:54:51', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\nStep 2: Update your CSS vendor prefixes\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\nStep 3: Get rid of browser sniffing methods\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n \r\n\r\nFeature Detection\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\n \r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n \r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n1.	Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.\r\n2.	Select the AutoResponder tab on the right.\r\n3.	Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.\r\n4.	Drag the selected session from the left panel into the AutoResponder tab.\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\nâ—	If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/\r\nâ—	Then respond with: *200-SESSION_3\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\nStep 4: Update touch and pointer events\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n \r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nTesting both experiences\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n1.	Press F12 to reveal the Developer Tools\r\n2.	Change your Document Mode to Internet Explorer 7 Standards\r\n3.	Refresh the page\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\nThat’s all!\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-4', '', '', '2012-04-09 11:54:51', '2012-04-09 15:54:51', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-4/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1848, 3, '2012-04-09 11:54:56', '2012-04-09 15:54:56', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\nStep 2: Update your CSS vendor prefixes\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\nStep 3: Get rid of browser sniffing methods\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n \r\n\r\nFeature Detection\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\n \r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n \r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n1.	Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.\r\n2.	Select the AutoResponder tab on the right.\r\n3.	Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.\r\n4.	Drag the selected session from the left panel into the AutoResponder tab.\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\nâ—	If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/\r\nâ—	Then respond with: *200-SESSION_3\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\nStep 4: Update touch and pointer events\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n \r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nTesting both experiences\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n1.	Press F12 to reveal the Developer Tools\r\n2.	Change your Document Mode to Internet Explorer 7 Standards\r\n3.	Refresh the page\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\nThat’s all!\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-5', '', '', '2012-04-09 11:54:56', '2012-04-09 15:54:56', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-5/', 0, 'revision', '', 0),
(1849, 3, '2012-04-09 11:57:25', '2012-04-09 15:57:25', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\n \r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n \r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n1.	Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.\r\n2.	Select the AutoResponder tab on the right.\r\n3.	Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.\r\n4.	Drag the selected session from the left panel into the AutoResponder tab.\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\nâ—	If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/\r\nâ—	Then respond with: *200-SESSION_3\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n \r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n1.	Press F12 to reveal the Developer Tools\r\n2.	Change your Document Mode to Internet Explorer 7 Standards\r\n3.	Refresh the page\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-6', '', '', '2012-04-09 11:57:25', '2012-04-09 15:57:25', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-6/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1850, 3, '2012-04-09 11:58:04', '2012-04-09 15:58:04', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\n \r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n \r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n1.	Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.\r\n2.	Select the AutoResponder tab on the right.\r\n3.	Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.\r\n4.	Drag the selected session from the left panel into the AutoResponder tab.\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\nâ—	If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/\r\nâ—	Then respond with: *200-SESSION_3\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n \r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n1.	Press F12 to reveal the Developer Tools\r\n2.	Change your Document Mode to Internet Explorer 7 Standards\r\n3.	Refresh the page\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-7', '', '', '2012-04-09 11:58:04', '2012-04-09 15:58:04', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-7/', 0, 'revision', '', 0),
(1851, 3, '2012-04-09 12:00:21', '2012-04-09 16:00:21', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-8', '', '', '2012-04-09 12:00:21', '2012-04-09 16:00:21', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-8/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1852, 3, '2012-04-09 12:00:28', '2012-04-09 16:00:28', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following on MSNBC:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as SASS and Compass, -prefix-free, or even CSS Snippets in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in A Best Practice for Programming with Vendor Prefixes on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is Modernizr. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our Developer Tools. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of http://www.msnbc.msn.com/id/37156949/.\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an AutoResponder for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for MSPointer events like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in http://www.msnbc.msn.com/id/43662671/15:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in http://www.msnbc.com/id/44937131/. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches TouchList. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see Handling Multi-touch and Mouse Input in All Browsers.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or document mode, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download Internet Explorer 10 (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-9', '', '', '2012-04-09 12:00:28', '2012-04-09 16:00:28', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-9/', 0, 'revision', '', 0),
(1853, 3, '2012-04-09 12:08:13', '2012-04-09 16:08:13', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-10', '', '', '2012-04-09 12:08:13', '2012-04-09 16:08:13', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-10/', 0, 'revision', '', 0),
(1854, 3, '2012-04-09 12:13:31', '2012-04-09 16:13:31', '', 'get-flash', 0, '', 'inherit', 'open', 'open', '', 'get-flash', '', '', '2012-04-09 12:13:31', '2012-04-09 16:13:31', '', 1843, 'http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png', 0, 'attachment', 'image/png', 0),
(1855, 3, '2012-04-09 12:14:12', '2012-04-09 16:14:12', '', 'find-userAgent', 0, '', 'inherit', 'open', 'open', '', 'find-useragent', '', '', '2012-04-09 12:14:12', '2012-04-09 16:14:12', '', 1843, 'http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png', 0, 'attachment', 'image/png', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1856, 3, '2012-04-09 12:08:24', '2012-04-09 16:08:24', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-11', '', '', '2012-04-09 12:08:24', '2012-04-09 16:08:24', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-11/', 0, 'revision', '', 0),
(1857, 3, '2012-04-09 12:14:25', '2012-04-09 16:14:25', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-12', '', '', '2012-04-09 12:14:25', '2012-04-09 16:14:25', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-12/', 0, 'revision', '', 0),
(1858, 3, '2012-04-09 12:15:00', '2012-04-09 16:15:00', '', 'fiddler-sessions', 0, '', 'inherit', 'open', 'open', '', 'fiddler-sessions', '', '', '2012-04-09 12:15:00', '2012-04-09 16:15:00', '', 1843, 'http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png', 0, 'attachment', 'image/png', 0),
(1859, 3, '2012-04-09 12:16:08', '2012-04-09 16:16:08', '', '20110920-pointer', 0, '', 'inherit', 'open', 'open', '', '20110920-pointer', '', '', '2012-04-09 12:16:08', '2012-04-09 16:16:08', '', 1843, 'http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png', 0, 'attachment', 'image/png', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1860, 3, '2012-04-09 12:14:32', '2012-04-09 16:14:32', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-13', '', '', '2012-04-09 12:14:32', '2012-04-09 16:14:32', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-13/', 0, 'revision', '', 0),
(1861, 3, '2012-04-09 12:16:20', '2012-04-09 16:16:20', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on -webkit properties, omitting the prefixes which target other browsers such as -o, -ms, and -moz. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is browser sniffing. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called feature detection.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the canPlayType method exists on our newly-created video tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a video element is, the canPlayType method will be present. If the video element is unknown to the browser, the canPlayType method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “Modernizrâ€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select Edit Response. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a pointer. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the pointerType property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like touchstart, touchmove, and touchend,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like MSPointerDown, MSPointerUP, and MSPointerMove.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like onresizeend and keyup. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the event.targetTouches <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the pageX and pageY properties from the first item in the TouchList, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf event.pageX is not found, we fall back to assigning the value of targetTouches[0].pageX to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to touchmove. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-14', '', '', '2012-04-09 12:16:20', '2012-04-09 16:16:20', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-14/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1862, 3, '2012-04-09 12:22:35', '2012-04-09 16:22:35', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-15', '', '', '2012-04-09 12:22:35', '2012-04-09 16:22:35', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-15/', 0, 'revision', '', 0),
(1863, 3, '2012-04-09 12:22:42', '2012-04-09 16:22:42', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-16', '', '', '2012-04-09 12:22:42', '2012-04-09 16:22:42', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-16/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1864, 3, '2012-04-09 12:28:34', '2012-04-09 16:28:34', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-17', '', '', '2012-04-09 12:28:34', '2012-04-09 16:28:34', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-17/', 0, 'revision', '', 0),
(1865, 3, '2012-04-09 12:28:46', '2012-04-09 16:28:46', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-18', '', '', '2012-04-09 12:28:46', '2012-04-09 16:28:46', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-18/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1866, 3, '2012-04-09 12:28:52', '2012-04-09 16:28:52', 'If you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-19', '', '', '2012-04-09 12:28:52', '2012-04-09 16:28:52', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-19/', 0, 'revision', '', 0),
(1867, 3, '2012-04-10 12:19:38', '2012-04-10 16:19:38', 'I''ve had the good fortune of working with my friend <a href="https://twitter.com/#!/jonathansampson">Jonathan Sampson</a> recently on figuring out how to help developers build plugin-free experiences. With IE10 Metro going plugin-free, it''s incredibly important to document steps to help developers provide their users with great experiences without the need for proprietary 3rd party add-ons.\n\nIf you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\n\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \n\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\n\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\n\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\n\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\n\n<h2>Step 2: Update your CSS vendor prefixes</h2>\n\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\n\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\n\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\n\n[code lang="css"]background: -webkit-gradient(\n  linear,\n  left top,\n  left bottom,\n  color-stop(1, rgba(192,192,192,.6)),\n  color-stop(0.5, rgba(0,0,0,.6))\n);[/code]\n\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \n\n[code lang="css"]background: -webkit-linear-gradient( \n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\nbackground: -moz-linear-gradient( \n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\nbackground: -ms-linear-gradient( \n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\nbackground: -o-linear-gradient( \n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\nbackground: linear-gradient(\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\n\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\n\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\n\n<h2>Step 3: Get rid of browser sniffing methods</h2>\n\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\n\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\n  // Load HTML5 Experience\n} else {\n  // Load Flash Experience\n}[/code]\n\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\n\nHere is an attempt to find the version of Internet Explorer. \n\n[code lang="javascript"]if ( tests.IE ) {\n  j = /msie.(\\d\\.\\d+)/i;\n  k = navigator.userAgent.match(j)[1];\n}[/code]\n\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\n\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\n\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\n\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\n\n<h2>Feature Detection</h2>\n\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\n\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\n  // Load HTML5 Video\n} else {\n  // Load Flash Video\n}[/code]\n\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\n\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\n\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\n\n[code lang="javascript"]if ( Modernizr.video ) {\n  // Load HTML5 Video\n}[/code]\n\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \n\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\n\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\n\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\n\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\n\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\n\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\n<li>Select the AutoResponder tab on the right.</li>\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\n\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\n\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\n<li>Then respond with: *200-SESSION_3</li></ul>\n\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\n\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\n  // Flash Experience\n}[/code]\n\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\n\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\n  // Flash Experience\n}[/code]\n\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\n\n<h2>Step 4: Update touch and pointer events</h2>\n\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\n\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\n\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\n\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\n\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\n} else {\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\n}[/code]\n\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\n\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\n\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\n\nWe’re going to update this to include the MSPointer events as well:\n\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\n} else {\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\n}[/code]\n\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \n\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\n\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\n  /* Start drag logic */\n} else \nif ( event.type == &quot;touchmove&quot; ) {\n  /* Drag logic */\n} else \nif ( event.type == &quot;touchend&quot; ) {\n  /* Complete drag logic */\n}[/code]\n\nWe’ll modify this to listen for all of the registered event types:\n\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\n  /* Start drag logic */\n} else \nif ( event.type.match( /move$/i ) ) {\n  /* Drag logic */\n} else \nif ( event.type.match( /(up|end)$/i ) ) {\n  /* Complete drag logic */\n}[/code]\n\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\n\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\n\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\n\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\n\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\n\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\n\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\n\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\n\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\n\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\n\n<h2>Testing both experiences</h2>\n\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\n\n<ol><li>Press F12 to reveal the Developer Tools</li>\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\n<li>Refresh the page</li></ol>\n\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\n\n<h2>Get it Done!</h2>\n\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\n\n<strong><em>Update: In the rush to get this post up, I realized that I forgot to thank and give credit to <a href="https://twitter.com/#!/jonathansampson">Jonathan Sampson</a> for helping investigate and write about the great techniques mentioned above. He was a huge help in generating many of these great techniques. Thanks JS!</em></strong>\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-autosave', '', '', '2012-04-10 12:19:38', '2012-04-10 16:19:38', '', 1843, 'http://blog.reybango.com/2012/04/10/1843-autosave/', 0, 'revision', '', 0);
INSERT INTO `wp_dyxkdh_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1868, 3, '2012-04-09 12:35:50', '2012-04-09 16:35:50', 'I''ve had the good fortune of working with my friend <a href="https://twitter.com/#!/jonathansampson">Jonathan Sampson</a> recently on figuring out how to help developers build plugin-free experiences. With IE10 Metro going plugin-free, it''s incredibly important to document steps to help developers provide their users with great experiences without the need for proprietary 3rd party add-ons.\r\n\r\nIf you’ve built a plug-in-free browsing experience for the iPad, a few changes will make it ready for the new <a href="http://blogs.msdn.com/b/ie/archive/2011/08/31/browsing-without-plug-ins.aspx">IE10 plug-in-free experience</a> on Windows 8. As more browsers adopt the plug-in-free approach, now is a good time to start thinking about it. I’ll show you how to do this in a few steps below by writing code that works well in all modern browsers.\r\n\r\nToday we’re going to work with a <a href="http://www.msnbc.msn.com/id/22825103/vp/46802160">MSNBC plug-in-free experience</a> for rich media. It breaks down to two things: styles and scripts. \r\n\r\nTo modify the files of MSNBC, I will be using a proxy application known as Fiddler. You can download this tool from <a href="http://fiddler2.com">http://fiddler2.com</a>. This tool allows me to modify remote files as though they were on my local machine. If you have direct access to your own site, you can ignore Fiddler, and work directly with your files. Fiddler provides a great way for testing changes without the risk of breaking your live site.\r\n\r\n<h2>Step 1: Declare Standards mode and valid markup for modern browsers</h2>\r\n\r\nIn order to use the HTML5 elements we’ll be utilizing below, you’ll first need to ensure that you are operating in standards mode. One way to ensure this is to include the HTML5 doctype at the top of your document:\r\n\r\n[code lang="html"]&lt;!DOCTYPE html&gt;[/code]\r\n\r\n<h2>Step 2: Update your CSS vendor prefixes</h2>\r\n\r\nThe CSS language is constantly in a state of change as new features are suggested, updated, and standardized. In order to allow developers to learn how to use these new features, browser vendors typically offer experimental implementations via prefixed properties.\r\n\r\nA key part of using vendor prefixes responsibly is to ensure that prefixes from each vendor are included in your site to allow for the broadest level of feature support. In many cases, especially when building an iPad-centric site, you may have focused solely on <em>-webkit</em> properties, omitting the prefixes which target other browsers such as <em>-o, -ms, and -moz</em>. The end result of this is that you greatly limit the target devices that can render your plugin-free site to as well as provide a degraded experience for users of other modern browsers, many of which could serve up equally engaging functionality.\r\n\r\nFor instance, we find the following <a href="http://www.msnbc.msn.com/id/45230852/a12">on MSNBC</a>:\r\n\r\n[code lang="css"]background: -webkit-gradient(\r\n  linear,\r\n  left top,\r\n  left bottom,\r\n  color-stop(1, rgba(192,192,192,.6)),\r\n  color-stop(0.5, rgba(0,0,0,.6))\r\n);[/code]\r\n\r\nWith the growing trend towards an HTML5 plugin-free experience, it’s important to expand these rules to provide the vendor prefixes of other major browsers as well. \r\n\r\n[code lang="css"]background: -webkit-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -moz-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -ms-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: -o-linear-gradient( \r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );\r\nbackground: linear-gradient(\r\n  top, rgba( 0, 0, 0, 0.0 ) 0%, rgba( 0, 0, 0, 0.6 ) 50% );[/code]\r\n\r\nWhile more verbose but the benefits to broad browser feature support certainly outweigh the extra typing involved. In addition, there are a number of great tools that can break down this workload, such as <a href="http://sass-lang.com/">SASS</a> and <a href="http://compass-style.org/">Compass</a>, <a href="http://leaverou.github.com/prefixfree/">-prefix-free</a>, or even <a href="http://www.asp.net/web-forms/videos/visual-studio-vnext/visual-studio-vnext-videos-css-editor-snippets">CSS Snippets</a> in the upcoming Visual Studio 2011.\r\n\r\nAlso, if you’re working predominantly in JavaScript and would like to save time determining which features are supported by your client’s browser, review the instructions in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx">A Best Practice for Programming with Vendor Prefixes</a> on the IEBlog.\r\n\r\n<h2>Step 3: Get rid of browser sniffing methods</h2>\r\n\r\nThere are two methods used to determine what the user’s browser and device are capable of. One method, which unfortunately is somewhat popular, is <em>browser sniffing</em>. This method consists of examining the navigator object for certain patterns or values.\r\n\r\n[code lang="javascript"]if ( navigator.userAgent.indexOf(&quot;iPad&quot;) &gt; -1 ) {\r\n  // Load HTML5 Experience\r\n} else {\r\n  // Load Flash Experience\r\n}[/code]\r\n\r\nThe above code looks at the user agent string for the value “iPadâ€, and if found delivers a plug-in-free HTML5 experience. Otherwise, it’s assumed you are on a device that has Flash installed. This will result in a broken experience for non-iPad users who are browsing with plug-ins disabled, even though their browser is capable of handling HTML5 features.\r\n\r\nHere is an attempt to find the version of Internet Explorer. \r\n\r\n[code lang="javascript"]if ( tests.IE ) {\r\n  j = /msie.(\\d\\.\\d+)/i;\r\n  k = navigator.userAgent.match(j)[1];\r\n}[/code]\r\n\r\nThe user agent string is tested for a pattern that attempts to target the version number. This pattern looks for a single digit, followed by a period, followed by any number of additional digits. While this test will find values like “MSIE 8.0â€ and “MSIE 9.0â€, it will not identify the latest version of Internet Explorer, which identifies itself as “MSIE 10.0â€, since only one digit is expected before the period.\r\n\r\nThese are just a couple examples of why browser sniffing is not a best practice. The user agent string is not immutable - it is a read-write value that is easily changed by plugins, or even the user. Most modern browsers include the ability to easily change this value from their development tools, which some users take advantage of to get around poorly-developed websites.\r\n\r\nIf we disable plugins, or visit MSNBC from a device/browser that doesn’t have Flash, we would expect it to attempt a plug-in-free experience. Unfortunately, this is not the case. Rather than seeing an HTML5 experience, we’re instead asked to download Flash. This is because the site puts the user in one of two categories: an iPad user, or a Flash-enabled user.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/get-flash-300x225.png" alt="" title="get-flash" width="300" height="225" class="alignleft size-medium wp-image-1854" /></a>\r\n\r\n<h2>Feature Detection</h2>\r\n\r\nRather than trying to guess what a browser is capable of by sniffing its user agent string (which will fail you eventually), it is much wiser to actually test features directly in the browser. If you wanted to test the browser’s ability to deliver video and audio via HTML5, you could actually attempt to create these elements via JavaScript, and see if the browser understands them. This practice is called <em>feature detection</em>.\r\n\r\n[code lang="javascript"]if ( !!document.createElement(“videoâ€).canPlayType  ) {\r\n  // Load HTML5 Video\r\n} else {\r\n  // Load Flash Video\r\n}[/code]\r\n\r\nIn the above example, we start by testing whether the <em>canPlayType</em> method exists on our newly-created <em>video</em> tag. We’re using double-negation to cast the response to a boolean. If the browser understands what a <em>video</em> element is, the <em>canPlayType</em> method will be present. If the video element is unknown to the browser, the <em>canPlayType</em> method will not exist. If this test passes, we load our HTML5 video. If the test does not pass, we attempt to load Flash. Deeper feature detection could take place here, since Flash may not be on the machine, or may be disabled.\r\n\r\nFeature detection is the preferred method of determining what a browser is capable of, since there is no guesswork involved. If the browser passes properly-constructed tests, it absolutely supports the features you would like to use.\r\n\r\nMany great tools exist to provide feature tests for you. Once such tool, which provides over 40 tests, is <a href="http://www.modernizr.com/">Modernizr</a>. This tool creates a global object called “<em>Modernizr</em>â€ which contains the results of your tests. With Modernizr, testing for HTML5 video support is extremely easy:\r\n\r\n[code lang="javascript"]if ( Modernizr.video ) {\r\n  // Load HTML5 Video\r\n}[/code]\r\n\r\nMSNBC engages in browser sniffing to see if the device accessing the page is an iPad or not. Our first step is to remove the browser sniffing code, and replace it with feature detection code. \r\n\r\nBefore we can modify browser sniffing code, we first need to locate it. While in Internet Explorer, pressing F12 will pull up our <a href="http://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx">Developer Tools</a>. Within the tools, open the Script tab and do a search for “userAgentâ€. This search will seek out any instance of this property name in all of the site’s script files. We’re interested in the result from line 41 of <a href="http://www.msnbc.msn.com/id/37156949/">http://www.msnbc.msn.com/id/37156949/</a>.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/find-userAgent-300x225.png" alt="" title="find-userAgent" width="300" height="225" class="alignleft size-medium wp-image-1855" /></a>\r\n\r\nNow that we know what we want to edit, we can open up Fiddler and load up our traffic. Once Fiddler is opened, perform a hard-refresh (Ctrl+F5 in IE) on the MSNBC page. This results in all of the page sessions being listed in Fiddler.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/fiddler-sessions-300x225.png" alt="" title="fiddler-sessions" width="300" height="225" class="alignleft size-medium wp-image-1858" /></a>\r\n\r\nLooking carefully, you’ll notice our resource is the third from the top. Next I will setup an <a href="http://fiddler2.com/Fiddler2/help/AutoResponder.asp">AutoResponder</a> for this session file so that anytime it is requested, my own custom file is substituted in the place of the server response:\r\n\r\n<ol><li>Right-click this session and select “Decode Selected Sessionsâ€ from the context menu.</li>\r\n<li>Select the AutoResponder tab on the right.</li>\r\n<li>Click the “Enable automatic responsesâ€ checkbox in the AutoResponder tab.</li>\r\n<li>Drag the selected session from the left panel into the AutoResponder tab.</li></ol>\r\n\r\nAt this point, you should have an entry within your AutoResponder tab with the following rules:\r\n\r\n<ul><li>If URI matches: EXACT:http://www.msnbc.msn.com/id/37156949/</li>\r\n<li>Then respond with: *200-SESSION_3</li></ul>\r\n\r\nRight-click the entry in the AutoResponder and select <em>Edit Response</em>. In the popup that follows, switch to the SyntaxView tab where we will find the source for this file. As expected, line 41 contains our browser sniffing code:\r\n\r\n[code lang="javascript"]if(!(navigator.userAgent.toLowerCase().indexOf(&quot;ipad&quot;)&gt;-1)){\r\n  // Flash Experience\r\n}[/code]\r\n\r\nRather than test the contents of the userAgent, we’re going to instead look for support for the HTML5 video tag. Switch the above condition to the following:\r\n\r\n[code lang="javascript"]if ( !document.createElement(&quot;video&quot;).canPlayType ) {\r\n  // Flash Experience\r\n}[/code]\r\n\r\nThis test checks to see if we cannot use the video element. If canPlayType comes back as undefined, it will be cast to true and the first code block will be entered, setting up the Flash experience.\r\n\r\n<h2>Step 4: Update touch and pointer events</h2>\r\n\r\nSafari supports both a touch event model and a mouse event model. Internet Explorer 10 groups touch, mouse, and stylus events into a single abstract item known as a <em>pointer</em>. In fact, Internet Explorer 10 is the first browser to work for all input types, across all devices. This abstraction cuts down drastically on the amount of effort involved to determine which event model you ought to bind to and how to detect user-interaction. This pointer is then handled through MSPointer events. If necessary, you can determine the type of pointer by accessing the <em>pointerType</em> property.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/04/20110920-pointer.png" alt="" title="20110920-pointer" width="264" height="272" class="alignleft size-full wp-image-1859" /></a>\r\n\r\nDue to the fact Internet Explorer doesn’t support Apple’s proprietary event model, which includes touch events like <em>touchstart, touchmove</em>, and <em>touchend</em>,  MSNBC’s event listeners will need to be amended to listen for <a href="http://msdn.microsoft.com/library/ie/hh673557.aspx#pointer_events">MSPointer events</a> like <em>MSPointerDown, MSPointerUP</em>, and <em>MSPointerMove</em>.\r\n\r\nDue to the difference in event model implementations, use a feature detection tool like Modernizr or code like this to target all major event models:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  myCanvas.addEventListener(&quot;MSPointerMove&quot;, paint, false);\r\n} else {\r\n  myCanvas.addEventListener(&quot;mousemove&quot;, paint, false);\r\n  myCanvas.addEventListener(“touchmoveâ€, paint, false);\r\n}[/code]\r\n\r\nMSNBC only supports touch events, which we will need to change so that visitors who happen to be using a mouse can still interact with the page:\r\n\r\nOur events are tied up in <a href="http://www.msnbc.msn.com/id/43662671/15">http://www.msnbc.msn.com/id/43662671/15</a>:\r\n\r\n[code lang="javascript"]document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\ndocument.addEventListener(&quot;touchend&quot;, touchHandler, false);[/code]\r\n\r\nWe’re going to update this to include the MSPointer events as well:\r\n\r\n[code lang="javascript"]if (window.navigator.msPointerEnabled) {\r\n  document.addEventListener(&quot;MSPointerDown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerMove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;MSPointerUp&quot;, touchHandler, false);\r\n} else {\r\n  document.addEventListener(&quot;touchstart&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchmove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;touchend&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousedown&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mousemove&quot;, touchHandler, false);\r\n  document.addEventListener(&quot;mouseup&quot;, touchHandler, false);\r\n}[/code]\r\n\r\nFirst we’re checking for the presence of pointers. Since the MSPointer covers the mouse, fingers, and pens, we don’t need anything else besides them. We fall back, if necessary, to provide both touch and mouse events. \r\n\r\nNext we need to create cases for these event types in <a href="http://www.msnbc.com/id/44937131/">http://www.msnbc.com/id/44937131/</a>. Currently, MSNBC starts with the following:\r\n\r\n[code lang="javascript"]if ( event.type == &quot;touchstart&quot; ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type == &quot;touchmove&quot; ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type == &quot;touchend&quot; ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nWe’ll modify this to listen for all of the registered event types:\r\n\r\n[code lang="javascript"]if ( event.type.match( /(down|start)$/i ) ) {\r\n  /* Start drag logic */\r\n} else \r\nif ( event.type.match( /move$/i ) ) {\r\n  /* Drag logic */\r\n} else \r\nif ( event.type.match( /(up|end)$/i ) ) {\r\n  /* Complete drag logic */\r\n}[/code]\r\n\r\nThe above uses the match method and a series of regular expressions to determine which event was raised. If the event raised ends with a case-insensitive “downâ€ or “startâ€, we begin our drag code. If the event ends with a case-insensitive “moveâ€, we perform the actual drag logic itself. And lastly, if the event ends with a case-insensitive “upâ€ or “endâ€, we end our dragging event. Note: other events may be caught here as well, like <em>onresizeend</em> and <em>keyup</em>. Be sure to consider this in your project.\r\n\r\nThe above is an implementation of Ted Johnson’s solution in <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\nThe drag logic itself initially relies upon the <em>event.targetTouches</em> <a href="https://developer.mozilla.org/en/DOM/TouchList">TouchList</a>. This member does not exist in Internet Explorer. The drag logic attempts to gather the <em>pageX</em> and <em>pageY</em> properties from the first item in the <em>TouchList</em>, however in Internet Explorer these values are found directly on the event object.\r\n\r\n[code lang="javascript"]var curX = event.targetTouches[0].pageX;[/code]\r\n\r\nUsing the logical OR operator, I instruct curX to hold the value of event.pageX as long as event.pageX is present on the event object. If this property is not found, look within the targetTouches list:\r\n\r\n[code lang="javascript"]var curX = event.pageX || event.targetTouches[0].pageX;[/code]\r\n\r\nIf <em>event.pageX</em> is not found, we fall back to assigning the value of <em>targetTouches[0].pageX</em> to our variable.\r\n\r\nAnother important item to keep in mind is that this site initially responds to <em>touchmove</em>. When this event is raised while touching the playlist, the code attempts to reposition the playlist based upon your touch movement. There is no hovering when it comes to touch - you’re either touching, or you’re not.\r\n\r\nNow that we have mouse events tied into this logic, we have introduced the possibility for hovering. So while touchmove is free to reposition our playlist when it is over the playlist, we don’t want to do the same for mousemove. In fact, we only want the mousemove event to reposition the playlist when the mouse button is pressed.\r\n\r\nFor further reading, and examples on how to target all browsers, see <a href="http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx">Handling Multi-touch and Mouse Input in All Browsers</a>.\r\n\r\n<h2>Testing both experiences</h2>\r\n\r\nRecall our feature detection from earlier, how we first check to see if HTML5 video support is in the user''s browser. If it is, we give them HTML5. If it is not, we give them Flash. One easy way to test our work is to use a browser, or <a href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx">document mode</a>, that doesn’t support HTML5 features. This is very easy to test with Internet Explorer:\r\n\r\n<ol><li>Press F12 to reveal the Developer Tools</li>\r\n<li>Change your Document Mode to Internet Explorer 7 Standards</li>\r\n<li>Refresh the page</li></ol>\r\n\r\nIf our feature detection condition was written properly, you should now be watching a Flash-based presentation. Switching your Document Mode back into Internet Explorer 9 Standards (or “Standardsâ€ if you’re using IE10), will return you to the HTML5 experience.\r\n\r\n<h2>Get it Done!</h2>\r\n\r\nHopefully this post helps to define the types of changes that will allow your iOS site to work properly in IE10 Metro and other plugin-free environments. By including best practices such as feature detection and responsibly using vendor prefixes for great new features, you should be able to provide your users a great experience, regardless of which browser or device they’re using.  To assist with testing in other plug-in-free environments, download <a href="http://ie.microsoft.com/testdrive/Info/Downloads/Default.html">Internet Explorer 10</a> (currently available only in the Windows 8 CP) and begin testing today!\r\n', 'iOS to IE10 Metro: Building Cross-Browser Plugin-Free Experiences', 0, '', 'inherit', 'open', 'open', '', '1843-revision-20', '', '', '2012-04-09 12:35:50', '2012-04-09 16:35:50', '', 1843, 'http://blog.reybango.com/2012/04/09/1843-revision-20/', 0, 'revision', '', 0),
(1870, 3, '2012-05-08 15:12:05', '2012-05-08 19:12:05', 'One of the things that I’m passionate about in my role at Microsoft is helping developers ensure that their sites provide an awesome experience in every browser. Yeah, yeah I know it seems odd that a Microsoft evangelist would say this but it’s the honest truth and anyone who’s worked with me before knows that I take great pride in this effort.\r\n\r\n<h2>We''re Not Supporting IE!</h2>\r\n \r\nToday, I came across this article on HackerNews which caught me totally by surprise:\r\n\r\n“<a href="http://news.ycombinator.com/item?id=3941799"><strong><em>We don''t support Internet Explorer, and we''re calling that a feature</em></strong></a>â€\r\n\r\nWhen I checked out the site entry, <a href="https://paydirtapp.com/blog/we-dont-support-ie/">it directed me</a> to a startup called Paydirt which has a very slick looking time-tracking & invoicing app. In their <a href="https://paydirtapp.com/blog/we-dont-support-ie/">blog post</a>, they rattled off a couple of reasons why they’re not supporting Internet Explorer and they were pretty upfront about it:\r\n\r\n<em>“That''s why we made a key decision at Paydirt: we don''t support IE - at all - and we don''t pretend to. You can''t even sign up for Paydirt using IE.â€</em>\r\n\r\nThey also mentioned that sensible browsers support cool features:\r\n\r\n<em>“Sensible browsers can do amazing things (canvas, SVG animations, CSS3, web-sockets, blazingly fast JS), and limiting usage to these lets Paydirt take full advantage of these new technologies.â€</em>\r\n\r\nSo of course, I had to dig in to figure out what magical features they were using that IE9, and especially IE10, didn’t handle.\r\n\r\n<h2>Um...it works in IE</h2>\r\n\r\nSure enough, when I tried to sign up, I was blocked. So I used the IE F12 tools to fake the Chrome user agent string and, bam, I was able to sign up with no issues. The signup was painless and I waded through the app with Chrome & IE side-by-side. As I went through, I didn’t notice any differences in the functionality. Buttons worked as expected, data was being saved and even panels with fading functionality worked as expected. I was stumped because I couldn’t see what was preventing a user from using Internet Explorer on this site.\r\n\r\n<a href="http://blog.reybango.com/wp-content/uploads/2012/05/pd-chrome.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/05/pd-chrome-150x150.png" alt="" title="pd-chrome" width="150" height="150" class="alignleft size-thumbnail wp-image-1874" /></a><a href="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie10.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie10-150x150.png" alt="" title="pd-ie10" width="150" height="150" class="alignleft size-thumbnail wp-image-1876" /></a><a href="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie9.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie9-150x150.png" alt="" title="pd-ie9" width="150" height="150" class="alignleft size-thumbnail wp-image-1875" /></a><a href="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie9w71.png"><img src="http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie9w71-150x150.png" alt="" title="pd-ie9w7" width="150" height="150" class="alignleft size-thumbnail wp-image-1896" /></a>\r\n<em>Chrome, IE10, IE9/Win8, IE9/Win7 Screenshots of Paydirt</em>\r\n\r\n<h2>Why is there code in here for IE support?</h2>\r\n\r\nNext, I dug into the code and again, didn’t see anything that I could pinpoint as an issue. In fact, the Paydirt team had done a nice job of laying out their site using standards-based code. This is precisely what you want to see; developers using standards. As I dug through more files, I came across their main CSS stylesheet called paydirt-e08a29afb369fe41806659f40ff86301.css. When I looked in it, two things immediately popped out:\r\n<ul>\r\n<li>They were using many CSS3 features supported since IE9, like transforms & border-radius, but just not adding the –ms vendor prefix entry</li>\r\n<li>They had the “-msâ€ prefix for CSS3 gradients which was added in IE10</li>\r\n<li>They added support for -khtml-box-shadow but not -ms-box-shadow???</li>\r\n</ul>\r\n\r\nThis threw me off because in their blog post, their concern was the IE didn’t offer amazing feature support yet many of the features they implemented are readily available in IE9. In addition, they had actually done some initial work on supporting CSS3 features that are vailable in IE10 (e.g.: transitions & CSS3 gradients).\r\n\r\nAt this point, I’m completely stumped because:\r\n<ul><li>Their site works great in both IE9 & IE10</li>\r\n<li>They’ve included support for some IE features in their CSS</li>\r\n<li>They want sensible browsers that do amazing things and everything they’re doing is supported by IE9 & IE10. All they have to do is add the “-msâ€ vendor prefix just like they did for Webkit and Firefox. (They didn’t support Opera either unfortunately).</li></ul>\r\n\r\n<h2>It works in IE so why not just Open it Up</h2>\r\n\r\nSo we’re left to wonder if IE issues are the real reason they didn’t support the browser. And trust me, I totally get the pain developers went through. I’ve only been with Microsoft for 2 years and was a web developer WAY before I joined them (even part of <a href="http://jquery.org/team">the jQuery project team</a>). But IE9, and especially IE10, have come an incredibly long way since the IE6-8 days and I’m having a hard time rationalizing Paydirt’s decision here – particularly since it’s exactly this type of behavior (writing for or against specific browsers) that sets the Web back again. \r\n\r\nMind you, if their only reason was that their traffic didn’t justify the support for IE6-8, I could understand it. But one of the things that Microsoft has been advocating for is the concept of “same markupâ€ and Paydirt is a great example of this. Despite them not wanting to support IE, because they used standards-based markup, the site just works in IE9 & IE10. And that totally contradicts Paydirt’s arguments about saving time and lack of feature support. Their site <strong>JUST WORKS</strong>!\r\n\r\nNow, it’s not to say that if you really dig deep you may not find some issue. That happens actually in every browser and is not unique to IE. But seriously Paydirt, do you really want to use these arguments when your site actually does render great in Internet Explorer? Have you checked it out? Perhaps being a Mac-based company, testing may be the issue. If it is, then let’s discuss the options.\r\n\r\nClaiming, though, that not supporting IE saves you time when your site is working just fine in IE9/10 is a tough sell. Let’s talk. I’m happy to help.\r\n\r\n<h2><em>Update: Closing comments on the post. Plenty of lively feedback which regardless of your stance, I truly appreciate.</em></h2>\r\n\r\n', 'Hey Paydirt: Your Site Works Just Fine in IE ', 0, '', 'publish', 'closed', 'closed', '', 'hey-paydirt-your-site-works-just-fine-in-ie', '', '', '2012-05-08 23:16:46', '2012-05-09 03:16:46', '', 0, 'http://blog.reybango.com/?p=1870', 0, 'post', '', 133),
(1871, 3, '2012-05-08 13:00:45', '2012-05-08 17:00:45', 'One of the things that I’m passionate about in my role at Microsoft is helping developers ensure that their sites provide an awesome experience in every browser. Yeah, yeah I know it seems odd that a Microsoft evangelist would say this but it’s the honest truth and anyone who’s worked with me before knows that I take great pride in this effort.\n \nToday, I came across this article on HackerNews which caught me totally by surprise:\n\n“<a href="http://news.ycombinator.com/item?id=3941799"><strong>We don''t support Internet Explorer, and we''re calling that a feature</strong></a>â€\n\nWhen I checked out the site entry, it directed me to a startup called Paydirt which has a very slick looking time-tracking & invoicing app. In their blog post, they rattled off a couple of reasons why they’re not supporting Internet Explorer and they were pretty upfront about it:\n“That''s why we made a key decision at Paydirt: we don''t support IE - at all - and we don''t pretend to. You can''t even sign up for Paydirt using IE.â€\nThey also mentioned that sensible browsers support cool features:\n“Sensible browsers can do amazing things (canvas, SVG animations, CSS3, web-sockets, blazingly fast JS), and limiting usage to these lets Paydirt take full advantage of these new technologies.â€\nSo of course, I had to dig in to figure out what magical features they were using that IE9, and especially IE10, didn’t handle.\nSure enough, when I tried to sign up, I was blocked. So I used the IE F12 tools to fake the Chrome user agent string and, bam, I was able to sign up with no issues. The signup was painless and I waded through the app with Chrome & IE side-by-side. As I went through, I didn’t notice any differences in the functionality. Buttons worked as expected, data was being saved and even panels with fading functionality worked as expected. I was stumped because I couldn’t see what was preventing a user from using Internet Explorer on this site.\nNext, I dug into the code and again, didn’t see anything that I could pinpoint as an issue. In fact, the Paydirt team had done a nice job of laying out their site using standards-based code. This is precisely what you want to see; developers using standards. As I dug through more files, I came across their main CSS stylesheet called paydirt-e08a29afb369fe41806659f40ff86301.css. When I looked in it, two things immediately popped out:\n•	They were using many CSS3 features supported since IE9, like transforms & border-radius, but just not adding the –ms vendor prefix entry\n•	They had the “-msâ€ prefix for CSS3 gradients which was added in IE10\n•	They added support for -khtml-box-shadow but not -ms-box-shadow???\nThis threw me off because in their blog post, their concern was the IE didn’t offer amazing feature support yet many of the features they implemented were available since IE9, a two-year old browser. And in addition, they had actually done some initial work on supporting CSS3 features that are available in IE10 (e.g.: transitions & CSS3 gradients).\nAt this point, I’m completely stumped because:\n•	Their site works great in both IE9 & IE10\n•	They’ve included support for some IE features in their CSS\n•	They want sensible browsers that do amazing things and everything they’re doing is supported by IE9 & IE10. All they have to do is add the “-msâ€ vendor prefix just like they did for Webkit and Firefox. (They didn’t support Opera either unfortunately).\nSo we’re left to wonder if IE issues are the real reason they didn’t support the browser. And trust me, I totally get the pain developers went through. I’ve only been with Microsoft for 2 years and was a web developer WAY before I joined them (even part of the jQuery project team). But I can honestly say that IE9, and especially IE10, have come an incredibly long way since the IE6-8 days and I’m having a hard time rationalizing Paydirt’s decision here. \nMind you, if their only reason was that their traffic didn’t justify the support for IE6-8, I could understand it. But one of the things that Microsoft has been advocating for is the concept of “same markupâ€ and Paydirt is a great example of this. Despite them not wanting to support IE, because they used standards-based markup, the site just works in IE9 & IE10. And that totally contradicts Paydirt’s arguments about saving time and lack of feature support. Their site JUST WORKS!\nNow, it’s not to say that if you really dig deep you may not find some issue. That happens actually in every browser and is not unique to IE. But seriously Paydirt, do you really want to use these arguments when your site actually does render great in Internet Explorer? Have you even checked it out? Perhaps being a Mac company, testing may be the issue. If it is, then let’s discuss the options.\nClaiming, though, that not supporting IE saves you time when your site is working just fine in IE9/10 is a tough sell. Let’s talk. I’m happy to help you work through the issues.\n\n\n\n', '', 0, '', 'inherit', 'open', 'open', '', '1870-revision', '', '', '2012-05-08 13:00:45', '2012-05-08 17:00:45', '', 1870, 'http://blog.reybango.com/2012/05/08/1870-revision/', 0, 'revision', '', 0),
(1872, 3, '2012-05-08 13:01:45', '2012-05-08 17:01:45', 'One of the things that I’m passionate about in my role at Microsoft is helping developers ensure that their sites provide an awesome experience in every browser. Yeah, yeah I know it seems odd that a Microsoft evangelist would say this but it’s the honest truth and anyone who’s worked with me before knows that I take great pride in this effort.\n \nToday, I came across this article on HackerNews which caught me totally by surprise:\n\n“<a href="http://news.ycombinator.com/item?id=3941799"><strong>We don''t support Internet Explorer, and we''re calling that a feature</strong></a>â€\n\nWhen I checked out the site entry, <a href="https://paydirtapp.com/blog/we-dont-support-ie/">it directed me</a> to a startup called Paydirt which has a very slick looking time-tracking & invoicing app. In their <a href="https://paydirtapp.com/blog/we-dont-support-ie/">blog post</a>, they rattled off a couple of reasons why they’re not supporting Internet Explorer and they were pretty upfront about it:\n\n<em>“That''s why we made a key decision at Paydirt: we don''t support IE - at all - and we don''t pretend to. You can''t even sign up for Paydirt using IE.â€</em>\n\nThey also mentioned that sensible browsers support cool features:\n“Sensible browsers can do amazing things (canvas, SVG animations, CSS3, web-sockets, blazingly fast JS), and limiting usage to these lets Paydirt take full advantage of these new technologies.â€\nSo of course, I had to dig in to figure out what magical features they were using that IE9, and especially IE10, didn’t handle.\nSure enough, when I tried to sign up, I was blocked. So I used the IE F12 tools to fake the Chrome user agent string and, bam, I was able to sign up with no issues. The signup was painless and I waded through the app with Chrome & IE side-by-side. As I went through, I didn’t notice any differences in the functionality. Buttons worked as expected, data was being saved and even panels with fading functionality worked as expected. I was stumped because I couldn’t see what was preventing a user from using Internet Explorer on this site.\nNext, I dug into the code and again, didn’t see anything that I could pinpoint as an issue. In fact, the Paydirt team had done a nice job of laying out their site using standards-based code. This is precisely what you want to see; developers using standards. As I dug through more files, I came across their main CSS stylesheet called paydirt-e08a29afb369fe41806659f40ff86301.css. When I looked in it, two things immediately popped out:\n•	They were using many CSS3 features supported since IE9, like transforms & border-radius, but just not adding the –ms vendor prefix entry\n•	They had the “-msâ€ prefix for CSS3 gradients which was added in IE10\n•	They added support for -khtml-box-shadow but not -ms-box-shadow???\nThis threw me off because in their blog post, their concern was the IE didn’t offer amazing feature support yet many of the features they implemented were available since IE9, a two-year old browser. And in addition, they had actually done some initial work on supporting CSS3 features that are available in IE10 (e.g.: transitions & CSS3 gradients).\nAt this point, I’m completely stumped because:\n•	Their site works great in both IE9 & IE10\n•	They’ve included support for some IE features in their CSS\n•	They want sensible browsers that do amazing things and everything they’re doing is supported by IE9 & IE10. All they have to do is add the “-msâ€ vendor prefix just like they did for Webkit and Firefox. (They didn’t support Opera either unfortunately).\nSo we’re left to wonder if IE issues are the real reason they didn’t support the browser. And trust me, I totally get the pain developers went through. I’ve only been with Microsoft for 2 years and was a web developer WAY before I joined them (even part of the jQuery project team). But I can honestly say that IE9, and especially IE10, have come an incredibly long way since the IE6-8 days and I’m having a hard time rationalizing Paydirt’s decision here. \nMind you, if their only reason was that their traffic didn’t justify the support for IE6-8, I could understand it. But one of the things that Microsoft has been advocating for is the concept of “same markupâ€ and Paydirt is a great example of this. Despite them not wanting to support IE, because they used standards-based markup, the site just works in IE9 & IE10. And that totally contradicts Paydirt’s arguments about saving time and lack of feature support. Their site JUST WORKS!\nNow, it’s not to say that if you really dig deep you may not find some issue. That happens actually in every browser and is not unique to IE. But seriously Paydirt, do you really want to use these arguments when your site actually does render great in Internet Explorer? Have you even checked it out? Perhaps being a Mac company, testing may be the issue. If it is, then let’s discuss the options.\nClaiming, though, that not supporting IE saves you time when your site is working just fine in IE9/10 is a tough sell. Let’s talk. I’m happy to help you work through the issues.\n\n\n\n', '', 0, '', 'inherit', 'open', 'open', '', '1870-revision-2', '', '', '2012-05-08 13:01:45', '2012-05-08 17:01:45', '', 1870, 'http://blog.reybango.com/2012/05/08/1870-revision-2/', 0, 'revision', '', 0),
(1873, 3, '2012-05-08 13:04:12', '2012-05-08 17:04:12', 'One of the things that I’m passionate about in my role at Microsoft is helping developers ensure that their sites provide an awesome experience in every browser. Yeah, yeah I know it seems odd that a Microsoft evangelist would say this but it’s the honest truth and anyone who’s worked with me before knows that I take great pride in this effort.\r\n \r\nToday, I came across this article on HackerNews which caught me totally by surprise:\r\n\r\n“<a href="http://news.ycombinator.com/item?id=3941799"><strong><em>We don''t support Internet Explorer, and we''re calling that a feature</em></strong></a>â€\r\n\r\nWhen I checked out the site entry, <a href="https://paydirtapp.com/blog/we-dont-support-ie/">it directed me</a> to a startup called Paydirt which has a very slick looking time-tracking & invoicing app. In their <a href="https://paydirtapp.com/blog/we-dont-support-ie/">blog post</a>, they rattled off a couple of reasons why they’re not supporting Internet Explorer and they were pretty upfront about it:\r\n\r\n<em>“That''s why we made a key decision at Paydirt: we don''t support IE - at all - and we don''t pretend to. You can''t even sign up for Paydirt using IE.â€</em>\r\n\r\nThey also mentioned that sensible browsers support cool features:\r\n\r\n<em>“Sensible browsers can do amazing things (canvas, SVG animations, CSS3, web-sockets, blazingly fast JS), and limiting usage to these lets Paydirt take full advantage of these new technologies.â€</em>\r\n\r\nSo of course, I had to dig in to figure out what magical features they were using that IE9, and especially IE10, didn’t handle.\r\nSure enough, when I tried to sign up, I was blocked. So I used the IE F12 tools to fake the Chrome user agent string and, bam, I was able to sign up with no issues. The signup was painless and I waded through the app with Chrome & IE side-by-side. As I went through, I didn’t notice any differences in the functionality. Buttons worked as expected, data was being saved and even panels with fading functionality worked as expected. I was stumped because I couldn’t see what was preventing a user from using Internet Explorer on this site.\r\n\r\nNext, I dug into the code and again, didn’t see anything that I could pinpoint as an issue. In fact, the Paydirt team had done a nice job of laying out their site using standards-based code. This is precisely what you want to see; developers using standards. As I dug through more files, I came across their main CSS stylesheet called paydirt-e08a29afb369fe41806659f40ff86301.css. When I looked in it, two things immediately popped out:\r\n<ul>\r\n<li>They were using many CSS3 features supported since IE9, like transforms & border-radius, but just not adding the –ms vendor prefix entry</li>\r\n<li>They had the “-msâ€ prefix for CSS3 gradients which was added in IE10</li>\r\n<li>They added support for -khtml-box-shadow but not -ms-box-shadow???</li>\r\n</ul>\r\n\r\nThis threw me off because in their blog post, their concern was the IE didn’t offer amazing feature support yet many of the features they implemented were available since IE9, a two-year old browser. And in addition, they had actually done some initial work on supporting CSS3 features that are available in IE10 (e.g.: transitions & CSS3 gradients).\r\n\r\nAt this point, I’m completely stumped because:\r\n<ul><li>Their site works great in both IE9 & IE10</li>\r\n<li>They’ve included support for some IE features in their CSS</li>\r\n<li>They want sensible browsers that do amazing things and everything they’re doing is supported by IE9 & IE10. All they have to do is add the “-msâ€ vendor prefix just like they did for Webkit and Firefox. (They didn’t support Opera either unfortunately).</li></ul>\r\n\r\nSo we’re left to wonder if IE issues are the real reason they didn’t support the browser. And trust me, I totally get the pain developers went through. I’ve only been with Microsoft for 2 years and was a web developer WAY before I joined them (even part of the jQuery project team). But I can honestly say that IE9, and especially IE10, have come an incredibly long way since the IE6-8 days and I’m having a hard time rationalizing Paydirt’s decision here. \r\n\r\nMind you, if their only reason was that their traffic didn’t justify the support for IE6-8, I could understand it. But one of the things that Microsoft has been advocating for is the concept of “same markupâ€ and Paydirt is a great example of this. Despite them not wanting to support IE, because they used standards-based markup, the site just works in IE9 & IE10. And that totally contradicts Paydirt’s arguments about saving time and lack of feature support. Their site <strong>JUST WORKS</strong>!\r\n\r\nNow, it’s not to say that if you really dig deep you may not find some issue. That happens actually in every browser and is not unique to IE. But seriously Paydirt, do you really want to use these arguments when your site actually does render great in Internet Explorer? Have you even checked it out? Perhaps being a Mac company, testing may be the issue. If it is, then let’s discuss the options.\r\n\r\nClaiming, though, that not supporting IE saves you time when your site is working just fine in IE9/10 is a tough sell. Let’s talk. I’m happy to help you work through the issues.\r\n\r\n\r\n\r\n', '', 0, '', 'inherit', 'open', 'open', '', '1870-revision-3', '', '', '2012-05-08 13:04:12', '2012-05-08 17:04:12', '', 1870, 'http://blog.reybango.com/2012/05/08/1870-revision-3/', 0, 'revision', '', 0),
(1874, 3, '2012-05-08 13:05:08', '2012-05-08 17:05:08', 'Chrome', 'pd-chrome', 0, '', 'inherit', 'open', 'open', '', 'pd-chrome', '', '', '2012-05-08 13:05:08', '2012-05-08 17:05:08', '', 1870, 'http://blog.reybango.com/wp-content/uploads/2012/05/pd-chrome.png', 0, 'attachment', 'image/png', 0),
(1875, 3, '2012-05-08 13:05:36', '2012-05-08 17:05:36', 'IE9', 'pd-ie9', 0, '', 'inherit', 'open', 'open', '', 'pd-ie9', '', '', '2012-05-08 13:05:36', '2012-05-08 17:05:36', '', 1870, 'http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie9.png', 0, 'attachment', 'image/png', 0),
(1876, 3, '2012-05-08 13:05:57', '2012-05-08 17:05:57', 'IE10', 'pd-ie10', 0, '', 'inherit', 'open', 'open', '', 'pd-ie10', '', '', '2012-05-08 13:05:57', '2012-05-08 17:05:57', '', 1870, 'http://blog.reybango.com/wp-content/uploads/2012/05/pd-ie10.png', 0, 'attachment', 'image/png', 0);
