<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tag 'JavaScript'</title><link>http://bloggingabout.net/search/SearchResults.aspx?a=1&amp;o=DateDescending&amp;tag=JavaScript&amp;orTags=0</link><description>Search results matching tag 'JavaScript'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Debugging JavaScript with Visual Studio in an ASP.NET MVC 4 application</title><link>http://bloggingabout.net/blogs/rick/archive/2012/12/19/debugging-javascript-with-visual-studio-in-an-asp-net-mvc-4-application.aspx</link><pubDate>Wed, 19 Dec 2012 05:27:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:578220</guid><dc:creator>Rick van den Bosch</dc:creator><description>&lt;p&gt;When debugging JavaScript in an ASP.NET MVC (4) application, it is not always enough to uncheck the &amp;#39;Disable script debugging&amp;#39; checkboxes under &amp;#39;Tools&amp;#39; - &amp;#39;Internet Options&amp;#39; - &amp;#39;Advanced&amp;#39; - &amp;#39;Browsing&amp;#39;. JavaScript inside a Razor view (a cshtml file) cannot be debugged from Visual Studio. To debug your JavaScript, move it to a separate .js file and link to that file from your Razor view. This way, breakpoints set in the JavaScript will be hit and you can debug from Visual Studio.&lt;/p&gt;
&lt;p&gt;Hope this helps&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:x-small;"&gt;Disclaimer: I know about the F12 Developer Tools, Firebug and all the other possibilities we have to debug JavaScript. This post is about getting JavaScript debugging to work with Visual Studio and breakpoints set in Visual Studio. For those who want it that way. So there... ;)&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Consuming JSON Web Service from jQuery and Server Code</title><link>http://bloggingabout.net/blogs/adelkhalil/archive/2009/09/03/consuming-json-web-service-from-jquery-and-server-code.aspx</link><pubDate>Thu, 03 Sep 2009 19:07:37 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482149</guid><dc:creator>Adel Khalil</dc:creator><description>&lt;p&gt;This is a trick i learned today, if you have your web service returning JSON string to utilize on your ajax calls if you planned to connect to this service using server code (Web Reference) for internal facing app for example you have a problem.&lt;/p&gt;  &lt;p&gt;If you are using HttpModule to alter the content-type to application/json you need to disabled this first, add web reference and then re-enable it again.&lt;/p&gt;  &lt;p&gt;when trying to add web reference with Visual Studio you can’t get valid disco/wsdl files however if you added the reference while disabling the HttpModule and re-enable it again, it works.&lt;/p&gt;  &lt;p&gt;Hope this helps.&lt;/p&gt;</description></item><item><title>Cross-domain JSONP with jQuery call step-by-step guide</title><link>http://bloggingabout.net/blogs/adelkhalil/archive/2009/08/14/cross-domain-jsonp-with-jquery-call-step-by-step-guide.aspx</link><pubDate>Thu, 13 Aug 2009 22:36:45 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482056</guid><dc:creator>Adel Khalil</dc:creator><description>&lt;p&gt;I’ve been banging my head all day to accomplish this, it’s like a puzzle.. but since i get it to work i thought i could write this post for you and myself.&lt;/p&gt;  &lt;h2&gt;What we want to accomplish?&lt;/h2&gt;  &lt;p&gt;Simple way to communicate cross-domain with ASMX .NET 3.5 Web Service&lt;/p&gt;  &lt;h2&gt;How can we do it?&lt;/h2&gt;  &lt;h3&gt;1. Implement a web service method like the following&lt;/h3&gt;  &lt;pre class="code"&gt;   [&lt;span style="color:#2b91af;"&gt;ScriptService&lt;/span&gt;]
   &lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;JSONP_EndPoint &lt;/span&gt;: System.Web.Services.&lt;span style="color:#2b91af;"&gt;WebService
   &lt;/span&gt;{
       [&lt;span style="color:#2b91af;"&gt;WebMethod&lt;/span&gt;]
       [&lt;span style="color:#2b91af;"&gt;ScriptMethod&lt;/span&gt;(UseHttpGet = &lt;span style="color:blue;"&gt;true&lt;/span&gt;,ResponseFormat = &lt;span style="color:#2b91af;"&gt;ResponseFormat&lt;/span&gt;.Json)]
       &lt;span style="color:blue;"&gt;public string &lt;/span&gt;Sum(&lt;span style="color:blue;"&gt;string &lt;/span&gt;x,&lt;span style="color:blue;"&gt;string &lt;/span&gt;y)
       {
           &lt;span style="color:blue;"&gt;return &lt;/span&gt;x + y;&lt;span style="color:green;"&gt;
       &lt;/span&gt;}
   }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h3&gt;2. Add New class library with a name ContentTypeHttpModule&lt;/h3&gt;

&lt;p&gt;The reason for this is no matter how you specify the content-type of your ajax call ASP.NET send the request with Content-Type text/xml; charset=utf-8 this is &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/04/04/json-hijacking-and-how-asp-net-ajax-1-0-mitigates-these-attacks.aspx"&gt;security feature explained here by ScottGu&lt;/a&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;3. Add the following code to your Class (&lt;a href="http://elegantcode.com/2008/12/02/calling-remote-aspnet-web-services-from-jquery/"&gt;Code by Jason&lt;/a&gt; i just did a simple modification)&lt;/h3&gt;

&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;using &lt;/span&gt;System;
&lt;span style="color:blue;"&gt;using &lt;/span&gt;System.Collections.Generic;
&lt;span style="color:blue;"&gt;using &lt;/span&gt;System.IO;
&lt;span style="color:blue;"&gt;using &lt;/span&gt;System.Linq;
&lt;span style="color:blue;"&gt;using &lt;/span&gt;System.Text;
&lt;span style="color:blue;"&gt;using &lt;/span&gt;System.Web;

&lt;span style="color:blue;"&gt;namespace &lt;/span&gt;ContentTypeHttpModule
{
    &lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;ContentTypeHttpModule &lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;IHttpModule
    &lt;/span&gt;{
        &lt;span style="color:blue;"&gt;private const string &lt;/span&gt;JSON_CONTENT_TYPE = &lt;span style="color:#a31515;"&gt;&amp;quot;application/json; charset=utf-8&amp;quot;&lt;/span&gt;;

        &lt;span style="color:blue;"&gt;#region &lt;/span&gt;IHttpModule Members
        &lt;span style="color:blue;"&gt;public void &lt;/span&gt;Dispose()
        {
        }

        &lt;span style="color:blue;"&gt;public void &lt;/span&gt;Init(&lt;span style="color:#2b91af;"&gt;HttpApplication &lt;/span&gt;app)
        {
            app.BeginRequest += OnBeginRequest;
            app.ReleaseRequestState += OnReleaseRequestState;
        }
        &lt;span style="color:blue;"&gt;#endregion

        public void &lt;/span&gt;OnBeginRequest(&lt;span style="color:blue;"&gt;object &lt;/span&gt;sender, &lt;span style="color:#2b91af;"&gt;EventArgs &lt;/span&gt;e)
        {
            &lt;span style="color:#2b91af;"&gt;HttpApplication &lt;/span&gt;app = (&lt;span style="color:#2b91af;"&gt;HttpApplication&lt;/span&gt;)sender;
            &lt;span style="color:#2b91af;"&gt;HttpRequest &lt;/span&gt;resquest = app.Request;
            &lt;span style="color:blue;"&gt;if &lt;/span&gt;(!resquest.Url.AbsolutePath.Contains(&lt;span style="color:#a31515;"&gt;&amp;quot;JSONP-EndPoint.asmx&amp;quot;&lt;/span&gt;)) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;

            &lt;span style="color:blue;"&gt;if &lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(app.Context.Request.ContentType))
            {
                app.Context.Request.ContentType = JSON_CONTENT_TYPE;
            }
        }

        &lt;span style="color:blue;"&gt;public void &lt;/span&gt;OnReleaseRequestState(&lt;span style="color:blue;"&gt;object &lt;/span&gt;sender, &lt;span style="color:#2b91af;"&gt;EventArgs &lt;/span&gt;e)
        {
            &lt;span style="color:#2b91af;"&gt;HttpApplication &lt;/span&gt;app = (&lt;span style="color:#2b91af;"&gt;HttpApplication&lt;/span&gt;)sender;
            &lt;span style="color:#2b91af;"&gt;HttpResponse &lt;/span&gt;response = app.Response;
            &lt;span style="color:blue;"&gt;if &lt;/span&gt;(app.Context.Request.ContentType != JSON_CONTENT_TYPE) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;

            response.Filter = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;JsonResponseFilter&lt;/span&gt;(response.Filter);
        }
    }

    &lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;JsonResponseFilter &lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;Stream
    &lt;/span&gt;{
        &lt;span style="color:blue;"&gt;private readonly &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;Stream &lt;/span&gt;_responseStream;
        &lt;span style="color:blue;"&gt;private long &lt;/span&gt;_position;

        &lt;span style="color:blue;"&gt;public &lt;/span&gt;JsonResponseFilter(&lt;span style="color:#2b91af;"&gt;Stream &lt;/span&gt;responseStream)
        {
            _responseStream = responseStream;
        }

        &lt;span style="color:blue;"&gt;public override bool &lt;/span&gt;CanRead { &lt;span style="color:blue;"&gt;get &lt;/span&gt;{ &lt;span style="color:blue;"&gt;return true&lt;/span&gt;; } }

        &lt;span style="color:blue;"&gt;public override bool &lt;/span&gt;CanSeek { &lt;span style="color:blue;"&gt;get &lt;/span&gt;{ &lt;span style="color:blue;"&gt;return true&lt;/span&gt;; } }

        &lt;span style="color:blue;"&gt;public override bool &lt;/span&gt;CanWrite { &lt;span style="color:blue;"&gt;get &lt;/span&gt;{ &lt;span style="color:blue;"&gt;return true&lt;/span&gt;; } }

        &lt;span style="color:blue;"&gt;public override long &lt;/span&gt;Length { &lt;span style="color:blue;"&gt;get &lt;/span&gt;{ &lt;span style="color:blue;"&gt;return &lt;/span&gt;0; } }

        &lt;span style="color:blue;"&gt;public override long &lt;/span&gt;Position { &lt;span style="color:blue;"&gt;get &lt;/span&gt;{ &lt;span style="color:blue;"&gt;return &lt;/span&gt;_position; } &lt;span style="color:blue;"&gt;set &lt;/span&gt;{ _position = &lt;span style="color:blue;"&gt;value&lt;/span&gt;; } }

        &lt;span style="color:blue;"&gt;public override void &lt;/span&gt;Write(&lt;span style="color:blue;"&gt;byte&lt;/span&gt;[] buffer, &lt;span style="color:blue;"&gt;int &lt;/span&gt;offset, &lt;span style="color:blue;"&gt;int &lt;/span&gt;count)
        {
            &lt;span style="color:blue;"&gt;string &lt;/span&gt;strBuffer = &lt;span style="color:#2b91af;"&gt;Encoding&lt;/span&gt;.UTF8.GetString(buffer, offset, count);
            strBuffer = AppendJsonpCallback(strBuffer, &lt;span style="color:#2b91af;"&gt;HttpContext&lt;/span&gt;.Current.Request);
            &lt;span style="color:blue;"&gt;byte&lt;/span&gt;[] data = &lt;span style="color:#2b91af;"&gt;Encoding&lt;/span&gt;.UTF8.GetBytes(strBuffer);
            _responseStream.Write(data, 0, data.Length);
        }

        &lt;span style="color:blue;"&gt;private string &lt;/span&gt;AppendJsonpCallback(&lt;span style="color:blue;"&gt;string &lt;/span&gt;strBuffer, &lt;span style="color:#2b91af;"&gt;HttpRequest &lt;/span&gt;request)
        {
            &lt;span style="color:blue;"&gt;return &lt;/span&gt;request.Params[&lt;span style="color:#a31515;"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;] +&lt;span style="color:#a31515;"&gt;&amp;quot;(&amp;quot; &lt;/span&gt;+ strBuffer + &lt;span style="color:#a31515;"&gt;&amp;quot;);&amp;quot;&lt;/span&gt;;
        }

        &lt;span style="color:blue;"&gt;public override void &lt;/span&gt;Close()
        {
            _responseStream.Close();
        }

        &lt;span style="color:blue;"&gt;public override void &lt;/span&gt;Flush()
        {
            _responseStream.Flush();
        }

        &lt;span style="color:blue;"&gt;public override long &lt;/span&gt;Seek(&lt;span style="color:blue;"&gt;long &lt;/span&gt;offset, &lt;span style="color:#2b91af;"&gt;SeekOrigin &lt;/span&gt;origin)
        {
            &lt;span style="color:blue;"&gt;return &lt;/span&gt;_responseStream.Seek(offset, origin);
        }

        &lt;span style="color:blue;"&gt;public override void &lt;/span&gt;SetLength(&lt;span style="color:blue;"&gt;long &lt;/span&gt;length)
        {
            _responseStream.SetLength(length);
        }

        &lt;span style="color:blue;"&gt;public override int &lt;/span&gt;Read(&lt;span style="color:blue;"&gt;byte&lt;/span&gt;[] buffer, &lt;span style="color:blue;"&gt;int &lt;/span&gt;offset, &lt;span style="color:blue;"&gt;int &lt;/span&gt;count)
        {
            &lt;span style="color:blue;"&gt;return &lt;/span&gt;_responseStream.Read(buffer, offset, count);
        }
    }
}&lt;/pre&gt;

&lt;h3&gt;4. Register the HttpModule in the service project&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;4.1 Add referance to the HttpModule assembly to the service project&lt;/p&gt;

  &lt;p&gt;4.2 Add this code to web.config to register the module&lt;/p&gt;

  &lt;p&gt;&amp;lt;add name=&amp;quot;ContentTypeHttpModule&amp;quot; 
    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type=&amp;quot;ContentTypeHttpModule.ContentTypeHttpModule, ContentTypeHttpModule&amp;quot; /&amp;gt;&lt;/p&gt;

  &lt;p&gt;This goes under system.web / httpmodules section&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;5. Add a web project for testing the application&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;5.1 add the following libs&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;jquery-1.3.1.js&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;json2.js&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;5.2 add new script file caller.js&lt;/p&gt;

  &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;function &lt;/span&gt;test() {
    $.ajax({ url: &lt;span style="color:#a31515;"&gt;&amp;quot;http://localhost:1690/JSONP-EndPoint.asmx/Sum&amp;quot;&lt;/span&gt;,
    data: { x: JSON.stringify(&lt;span style="color:#a31515;"&gt;&amp;quot;Now i am getting jsop string&amp;quot;&lt;/span&gt;), y: JSON.stringify(&lt;span style="color:#a31515;"&gt;&amp;quot;2nd param&amp;quot;&lt;/span&gt;) },
        dataType: &lt;span style="color:#a31515;"&gt;&amp;quot;jsonp&amp;quot;&lt;/span&gt;,
        success: &lt;span style="color:blue;"&gt;function&lt;/span&gt;(json) {
            alert(json.d);
        },
        error: &lt;span style="color:blue;"&gt;function&lt;/span&gt;() {
            alert(&lt;span style="color:#a31515;"&gt;&amp;quot;Hit error fn!&amp;quot;&lt;/span&gt;);
        }
    });
}&lt;/pre&gt;

  &lt;pre class="code"&gt;5.3 Add referances to &lt;em&gt;jquery-1.3.1.js&lt;/em&gt; and &lt;em&gt;json2.js&lt;/em&gt;&lt;/pre&gt;

  &lt;pre class="code"&gt;5.4 Add Default.aspx page with input button that has onclick=”return test();”&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;h3&gt;6. Remarks&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;6.1 I use the JSON.stringify function to serialize the string data parameters.&lt;/p&gt;

  &lt;p&gt;6.2 .d is a security features on ASP.NET 3.5&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;&lt;a href="http://bloggingabout.net/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/adelkhalil/2146.JSONP_2D00_Prototype.zip"&gt;Download the code&lt;/a&gt;&lt;/h2&gt;</description></item><item><title>Statistics about Browsers, JavaScript, Operating Systems, Rich Internet Application plug-ins and top sites</title><link>http://bloggingabout.net/blogs/harold/archive/2009/06/07/statistics-about-browsers-javascript-operating-systems-rich-internet-application-plug-ins-and-top-sites.aspx</link><pubDate>Sun, 07 Jun 2009 15:48:03 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:481772</guid><dc:creator>hvdkamp</dc:creator><description>&lt;p&gt;Here you have a list of statistics related to web sites or web applications:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Browser usage statistics, e.g. Internet Explorer, Mozilla FireFox, Google Chrome, Apple Safari and Opera: &lt;a title="http://www.w3schools.com/browsers/browsers_stats.asp" href="http://www.w3schools.com/browsers/browsers_stats.asp"&gt;http://www.w3schools.com/browsers/browsers_stats.asp&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;JavaScript statistics: &lt;a title="http://www.w3schools.com/browsers/browsers_stats.asp" href="http://www.w3schools.com/browsers/browsers_stats.asp"&gt;http://www.w3schools.com/browsers/browsers_stats.asp&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Browser display statistics, e.g. display resolution and color depth: &lt;a title="http://www.w3schools.com/browsers/browsers_display.asp" href="http://www.w3schools.com/browsers/browsers_display.asp"&gt;http://www.w3schools.com/browsers/browsers_display.asp&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Operating System statistics, e.g. Windows, Linux and Mac: &lt;a title="http://www.w3schools.com/browsers/browsers_os.asp" href="http://www.w3schools.com/browsers/browsers_os.asp"&gt;http://www.w3schools.com/browsers/browsers_os.asp&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Rich Internet Application (RIA) plug-in deployment statistics, e.g. Adobe Flash/Flex Player, Microsoft Silverlight Player and Sun Java: &lt;a title="http://riastats.com" href="http://riastats.com"&gt;http://riastats.com&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Shockwave Player Adoption statistics: &lt;a title="http://www.adobe.com/products/player_census/shockwaveplayer/" href="http://www.adobe.com/products/player_census/shockwaveplayer/"&gt;http://www.adobe.com/products/player_census/shockwaveplayer/&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Alexa’s top 500 sites on the web: &lt;a title="http://www.alexa.com/topsites" href="http://www.alexa.com/topsites"&gt;http://www.alexa.com/topsites&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;</description></item><item><title>JavaScript Hall of Shame</title><link>http://bloggingabout.net/blogs/program.x/archive/2008/12/16/javascript-hall-of-shame.aspx</link><pubDate>Tue, 16 Dec 2008 17:00:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:478034</guid><dc:creator>Nathan Pledger</dc:creator><description>&lt;p&gt;Here&amp;#39;s another pet hate in web bad-practice: Javascript. Javascript is a client-side scripting language that allows really useful interaction to occur with the page and the browser, thereby improving the end user experience when using a site. It&amp;#39;s very easy to insert Javascript in a page, not so easy to do it right.&lt;/p&gt;
&lt;p&gt;I despair when I look at many people&amp;#39;s sites, blogs and networks due to JavaScript errors. It really spoils the experience for me. If I follow a link to a site with the promise of interesting content, I do not want to be presented with a series of JavaScript errors in order to get to that content. I&amp;#39;ll just leave. Over the past couple of weeks, (since 1st December to be exact), I have been collecting some of the sites that have JavaScript errors on them (in Internet Explroer 7):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rik Talavera&amp;#39;s site &lt;a href="http://riktalavera.com/"&gt;http://riktalavera.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Google Reader &lt;a href="http://www.google.com/reader"&gt;http://www.google.com/reader&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Chris Brogan&amp;#39;s &lt;a title="Chris Brogan&amp;#39;s Newsletter Page" href="http://www.chrisbrogan.com/newsletters/"&gt;Newsletter Page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Facebook (of course) &lt;a href="http://www.facebook.com"&gt;http://www.facebook.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;TwitPic (on their &lt;a title="TwitPic (external link)" href="http://www.twitpic.com/"&gt;home page&lt;/a&gt;!)&lt;/li&gt;
&lt;li&gt;&lt;a title="TechCrunch (external link)" href="http://www.techcrunch.com/2008/07/15/confirmed-twitter-acquires-summize-search-engine/"&gt;TechCrunch&lt;/a&gt; (prepare to be annoyed)&lt;/li&gt;
&lt;li&gt;Bizarrely, a page on &lt;a title="JavaScript Exception Handling at DevShed (external link)" href="http://www.devshed.com/c/a/JavaScript/JavaScript-Exception-Handling/"&gt;Javascript Exception Handling&lt;/a&gt;&amp;nbsp;(see screenshot below)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/program.x/javascriptError.jpg"&gt;&lt;img src="http://bloggingabout.net/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/program.x/javascriptError.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;JavaScript errors can occur due to a number of problems, which bloggers/webmasters aren&amp;#39;t always bothered about. From the most basic blog with a Twitter feed to advanced sites such as Facebook, the result of a Javascript error is the same: unwanted behaviour often accompanied by error messages that mean nothing to the end user.&lt;/p&gt;
&lt;p&gt;There are a number of excellent resources for getting JavaScript snippets to add to your own site, many of them contributed to by &amp;quot;real&amp;quot; Javascript programmers more capable of handling Javascript code than me. Unfortunately, however, differing scripting dialects and runtimes mean that sometimes these scripts haven&amp;#39;t been thoroughly tested on all browsers. &lt;/p&gt;
&lt;p&gt;The increase in social networking, &amp;quot;widgets&amp;quot; and advertising services such as Google Adwords results in external Javascript being injected into the page in order to facilitate a particular requirement. For example, on the home page of &lt;a href="http://www.programx.co.uk"&gt;my site&lt;/a&gt; is a &lt;a title="Twitter (external link)" href="http://www.twitter.com"&gt;Twitter&lt;/a&gt; script that gets my Twitter status from Twitter and injects it into the Document Object Model (DOM) of my home page. It&amp;#39;s really neat. But if Twitter fails (as it regularly does) or the JavaScript doesn&amp;#39;t work with my browser for whatever reason, I will get a JavaScript error - and it will be beyond my control. If possible, it&amp;#39;s a good idea to pull the scripts off the remote servers and host them locally so you can react better in the case of an error.&lt;/p&gt;
&lt;p&gt;As JavaScript essentially runs in accordance with the page load cycle, it requires that the programmer has made resources available in the right place and in the right order for scripts to run flawlessly. If the page load is disrupted somehow, then errors may be caused which could remove functionality from the page. For example, if I load invoke a script in the HEAD of a page, which relies on a control in the BODY, the control would not be rendered when the script executes, thereby generating an error. A simple error, but one which is often forgotten about particularly as network speeds get faster. It becomes easier to assume the user&amp;#39;s page loads as fast as yours. If a script resource gets &amp;quot;held back&amp;quot; over the network for whatever reason, preceding scripts could easily fail. &lt;/p&gt;
&lt;p&gt;There is a definite trend to making the web browser work more like a desktop application with every new web application released. Google is particularly focused on the RIA (Rich Internet Application) which uses techniques such as AJAX to create the impression of a responsive and fully functional application within the web browser. Unfortunately, the script behind these applications is bound to be very complex and errors easily creep in. Take Google Reader, it doesn&amp;#39;t work on my copy of IE7. Take GMail, it regularly fails on IE7. The complexity of the applications is no excuse. Windows is a complex product but users will (rightly) criticise it and damn the product when it fails to work. The same should go for web sites that use faulty JavaScript. Users of Sitecore will know the powerful Content Editing environment that runs using extensive Javascript - it works fine. The only time I get JavaScript errors are when I cause them by fiddling with my browsing context (eg. Internet -&amp;gt; Intranet zones), etc.&lt;/p&gt;
&lt;p&gt;I can almost hear the cries, &amp;quot;use Firefox 3.1&amp;quot; and &amp;quot;use Google Chrome&amp;quot;, due to their JavaScript optimisation. Why should I? I use a browser that is easy to access and is on every machine&amp;nbsp;I touch - that is IE 7, which occupies the majority of the browser market. If you write an web/JavaScript application, it should work on ALL browsers, within reason. &lt;/p&gt;
&lt;p&gt;By &amp;quot;All Browsers&amp;quot;,&amp;nbsp;I mean:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Internet Explorer 7&lt;/li&gt;
&lt;li&gt;Internet Explorer 6&lt;/li&gt;
&lt;li&gt;Firefox 2&lt;/li&gt;
&lt;li&gt;Firefox 3&lt;/li&gt;
&lt;li&gt;Safari&lt;/li&gt;
&lt;li&gt;Google Chrome&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;#39;ll notice that I have not included beta versions of browsers (although I do test my work on these when I believe it is relevant - ie. close to release) and I have gone back a version for the two main browsers, Internet Explorer and Firefox. If your Javascript doesn&amp;#39;t work in all these browsers, or degrade gracefully, you really shouldn&amp;#39;t release the code.&lt;/p&gt;
&lt;p&gt;The JavaScript error message is a jarring experience and spoils many a site. The most attractive site can be ruined by a JavaScript error or two.&amp;nbsp;Just because your browser places a little yellow triangle on the status bar indicating an error has occured in the page, doesn&amp;#39;t mean other users have adopted the same configuration. The average user, who has stumbled on a page with a scrpt error, would not understand why certain aspects of the page are unresponsive as a result of any errors that have occured.&lt;/p&gt;
&lt;p&gt;My view on JavaScript best practice is: not to use it. If you have to use it, make sure it is error checked and gracefully degrades functionality if required. Also, make sure that alternative functionality is available if the functionality it provides is important to the use of the site. I would struggle to find any reason for JavaScript to be on any &amp;quot;front-end&amp;quot; site, whether it is a blog, corporate site or e-Commerce outlet. Javascript should be a complement to a well designed site, which should add value to the user experience. Tickers, counters, advertisements, etc. are not essential to the content on a page.&lt;/p&gt;
&lt;p&gt;There are few things more satisfying in using a web page than when a subtle visual cue is provided to indicate an action has been actioned. Facebook has a number of scripts that allow you to click on text to edit it and then apply it, for example, when updating your status. It&amp;#39;s all happening client-side, with minimal AJAX. It works really well - when JavaScript is available and the script works. If for whatever reason JavaScript isn&amp;#39;t available (maybe the browsing platform doesn&amp;#39;t support it), there is the alternative of typing it in (in most cases) and clicking &amp;#39;Post&amp;#39;. &lt;/p&gt;
&lt;p&gt;Also, remember that search engines will ignore JavaScript. As I always say, your biggest user is deaf, dumb and blind, and that is the search engine. You have to treat the search engine as if it is a base-level browser as a first step of Search Engine Optimisation (SEO), then adding on additional optimisations both for SEO and user experience, which means JavaScript gets added last and does not prevent loading of the page by search engines. I have seen sites that load the next page in the navigation sequence using JavaScript and while it is all very clever in technique, it is not clever in practice. The search bots are getting cleverer all the time and there are rumours of automated JavaScript execution engines that attempt to mimic a user, but these cannot be gauranteed and therefore you should not wrap content only within JavaScript.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;If I can, I always look for tried and tested components, rather then develop my own Javascript. I know my limitations, and Javascript isn&amp;#39;t a strong point. But when I need it, I&amp;#39;ll make sure it works, or look for a component I know will work and will have support behind it. That is why I use Telerik&amp;#39;s &lt;a title="Telerik ASP.NET AJAX UI Controls (external link)" href="http://www.telerik.com/products/aspnet-ajax.aspx"&gt;RadControls for ASP.NET AJAX&lt;/a&gt; for situations where I need complex client-side functionality, possibly to create an RIA experience. I can pay for the components, know that the testing has already been done and assuming I do my work right, should just be able to &amp;quot;drop in&amp;quot; the components and tweak accordingly.&lt;/p&gt;
&lt;p&gt;If you are working with JavaScript, good practice is to turn on JavaScript errors in your browser. That way, no matter what rush there is to launch a site, a script error will always be important - because it will directly annoy you everytime it happens. I turn on script debugging and error messages as part of my web work as standard, and it pays off in my site quality.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update (23 December 2008):&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This has been a popular post, and I&amp;#39;d like to thank Jim Connolly for his feedback. After reading this post, he checked the&amp;nbsp;page about&amp;nbsp;&lt;/strong&gt;&lt;a title="Advertising on Jim Connolly&amp;#39;s site (external link)" href="http://jimsmarketingblog.com/2008/12/13/no-advertising-or-sponsors/"&gt;&lt;strong&gt;Advertising on his site&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&amp;nbsp;and all seems well now. It&amp;#39;s good to see that we share the same views on web site quality, as he was very prompt about addressing the issue and contacting me about it.&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll keep this list up to date and will name and shame sites that fail to trap JavaScript issues. I encourage you to do the same, if you find a site you&amp;#39;re struggling to use, feel free to leave a comment and I&amp;#39;ll add it to my list.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Finally Microsoft Shipping Open Source</title><link>http://bloggingabout.net/blogs/adelkhalil/archive/2008/09/29/finally-microsoft-shipping-open-source.aspx</link><pubDate>Mon, 29 Sep 2008 00:53:16 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:474878</guid><dc:creator>Adel Khalil</dc:creator><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is awesome, Microsoft finally decided to ship open source software, jQuery will be shipped with ASP.NET MVC and will be supported as any Microsoft product, also will be shipped with Visual Studio on the long run, this is a bold move&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx" href="http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx"&gt;http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx" href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Suppressing JavaScript Error Messeges - Application/Page Level</title><link>http://bloggingabout.net/blogs/adelkhalil/archive/2008/05/12/suppressing-javascript-error-messeges-application-page-level.aspx</link><pubDate>Mon, 12 May 2008 03:33:55 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:458929</guid><dc:creator>Adel Khalil</dc:creator><description>&lt;p&gt;if you having problem with Ajax Extensions, Ajax Toolkit controls..etc generating bad JavaScript code that cause the message &amp;quot;Error On Page&amp;quot; to appear on the status bar of your browser then you can&amp;#39;t solve this by resolving the error or wrappe the whole thing in try/catch blocks.&lt;/p&gt; &lt;p&gt;What you need is suppress the error on a whole page, specific or on master page to simulate application level effect using this snippet in the HEAD section.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;lt;SCRIPT language=&amp;quot;JavaScript&amp;quot;&amp;gt; &lt;/p&gt; &lt;p&gt;function silentErrorHandler() {&lt;/p&gt; &lt;p&gt;return true;&lt;/p&gt; &lt;p&gt;} &lt;/p&gt; &lt;p&gt;window.onerror=silentErrorHandler; &lt;/p&gt; &lt;p&gt;&amp;lt;/SCRIPT&amp;gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Happy Coding..&lt;/p&gt;</description></item></channel></rss>