With Visual Studio 2008 I've done something I never thought I'd do. I'm actually using a beta of Visual Studio to write production code at work. I'm doing that not because it's the most stable platform, it's at beta 1 quality right now. I'm using it because of all the great features it adds as well as the unique ability that it can now target a .NET Framework that is different from the one it was written for. More on that in another post.
The reason that I'm writing this post is to point you to a blog by Scott Guthrie that he posted yesterday. It is describing the great and wonderful features of JavaScript Intellisense in Visual Studio 2008. I highly recommend reading this post:
http://weblogs.asp.net/scottgu/archive/2007/06/21/vs-2008-javascript-intellisense.aspx
Posted: 23 June 2007 by Todd Anthony Spatafore
I've noticed a disturbing trend lately with regards to the onload event of an HTML page. This trend includes one developer overwriting the onload event with their own function. I've seen some web pages that have this for the body tag:
<body onload="myLoadFunction();">
And because this doesn't seem to work for them they put this right before the closing body tag:
<script type="text/javascript">
myLoadFunction();
</script>
</body>
They do this without first finding out why the onload doesn't work. The issue is that in one of the many script libraries that they've included in their document is a function that destructively adds its own onload function into the DOM.
In a JavaScript book that I read a while ago the author included this code for adding an onload function in a non-destructive way:
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload =
function()
{
oldonload();
func();
};
}
}
To use this after your function that you want to add to the onload event just call:
addLoadEvent(myFuncName);
I believe I got this function from the O'Reilly book "JavaScript: The Definitive Guide" by David Flanagan.
If you are using the Prototype framework you can just use the observe method on the Event object to do this. More information can be found here.
Posted: 04 June 2007 by Todd Anthony Spatafore
Lately there's been a slew of new technologies promising to kill AJAX once and for all. Those technologies include Silverlight, Flex, and JavaFX. The problem with this theory is that all three require the user to install a plug-in. You cannot expect that a user will have your plug-in installed, and you shouldn't expect the user to install your plug-in just because you tell them to.
Personally I dislike Flash web sites. They are slow and bulky and they ruin the bookmark/Forward/Back experience of the web browser. Now there's promise that one of these new technologies will take over your browser, well I wouldn't count on it.
I'll grant you that AJAX itself also breaks the bookmark/forward/back mechanism, but that's only when it's not used correctly. I think there is a danger that these new technologies will be used to build entire web sites (as this is what is what we were told we could do last week at Mix 07). They should be used to enhance web pages, but don't forget that visitors to your site want to be able to move around in a method that is familiar to them.
Posted: 10 May 2007 by Todd Anthony Spatafore