Tag Archives: Event

Cross-browser event hookup made easy

I seem to be on a roll. I’m coding and might as well be sharing some of what I’m working on while I do it. In that sense, here goes another small bit of code that I’ll be adding to jsSimple on github.

We all know how to hook up events cross-browser. We know that we have both attachEvent and addEventListener. Both have varying syntax and we’ve all written this code a million times. Let’s just make this simple. Here’s how to call this:

Event.add(element, 'click', callback, false);
// .. 
Event.remove(element, 'click', callback, false);

The remove looks like you’re passing around the same data, so I added a return value to “add” that allows you to capture the event and pass it in as a single object to the remove function as follows:

var evt = Event.add(element, 'click', callback, false);
// .. 

So, without further delay, here is the object definition:

 * jsSimple v0.0.1
 * www.jssimple.com
 * Copyright (c) Tobin Titus
 * Available under the BSD and MIT licenses: www.jssimple.com/license/
var EventObj = function (target, type, listener, capture) {
  return {
    'target' : target,
    'type' : type,
    'listener' : listener,
    'capture' : capture

var Event = (function() {
  'use strict';
  function add (target, type, listener, capture) {
    capture = capture || false;
    if (target.addEventListener) {
      target.addEventListener(type, listener, capture);
    } else if (target.attachEvent) {
      target.attachEvent("on" + type, listener);
    return new EventObj(target, type, listener, capture);
  function remove(object, type, listener, capture) {
    var target;
    if (object && !type && !listener && !capture) {
      type = object.type;
      listener = object.listener;
      capture = object.capture;
      target = object.target;
    } else {
      capture = capture || false;
      target = object;
    if (target.removeEventListener) {
      target.removeEventListener(type, listener, capture);
    } else if (target.detachEvent) {
      target.detachEvent("on" + type, listener);
  return {
    'add' : add,
    'remove' : remove

You can see this all in action on jsFiddle.

Tuesday, January 17th – Greenville .NET user group

I’ve been having a blast presenting the latest and greatest Microsoft development tools and technologies to the entire state of South Carolina. In October, I was asked at the last minute to give a presentation on the new features of ASP.NET 2.0 to the Columbia, South Carolina .NET user group. In November, I had the pleasure of presenting Visual Studio 2005 Team System to the Greenville, SC user group. I ended the year doing ASP.NET 2.0 again for the Charleston .NET user group in December. I’ll be continuing this tour by presenting ASP.NET 2.0 to the Greenville .NET user group meeting this month. If you are interested in learning about some of the newest and best features of ASP.NET 2.0, come on out and visit the guild. We’d be glad to have you out.

Visual Studio 2005 Community Launch Tools

This year, I was asked to be the INETA community launch champion for my local user group. Essentially, the job is to present at least two topics related to Visual Studio 2005 and/or SQL Server 2005 and/or BizTalk 2006. I was honored to be picked for this role and have done my best to provide the best possible experience for those who come to listen. This month’s topic is “Managing the Software Development Life Cycle with Visual Studio 2005 Team System”. WOW! Here’s the blurb that the UG’s sent out on this topic:

“Today’s software projects have one consistent trait – they fail. They fail to meet budgets. They fail to meet deadlines. In many instances, they fail to even make it to implementation. In 2000, only a fraction of software projects succeeded. That rate did not get much better in 2004. Industry demands such as more complex business requirements, government regulations, and standardization of components will make success all the more challenging. In this presentation, we’ll explore how you can utilize the new tools found in Visual Studio Team Services to increase your own success track record. This presentation will show how requirements can be gathered early, managed, modified, tracked, and reported on all the way through the software development life cycle. Come see the powerful new tools that are provided for architects, developers, testers, project managers, business analysts, and even project stake holders!”

While its always a good thing to prepare for a meeting, I realized while sitting in my hotel room that there are quite a few tools that I use to give presentations. I thought I might post pictures and informationa bout the tools I use so that others who are just getting started in their presentation careers can get a glimps into their future.

The Laptop

Its an HP Pavilion zd8000 series laptop that has been customized for the best performance I can get out of it. It has 2GB of ram, a 100 GB hard drive, Lightscribe DVD burner, and the like. I love this laptop because it has 4 USB ports (5 if you count the HP usb digital drive port), firewire, built in wireless, bluetooth, 5-1 media reader, built in speakers, and the list goes on. It even has a media remote control (meant for use with Windows Media Center Edition) that works very well for remotely moving forward and backward in powerpoint slides. Its a varitable swiss army knife of laptops and the kicker, of course, is the 17″ widescreen LCD.


The External Hard Drive

I use a Maxtor 300GB exernal hard drive to keep all of my VPC images on. This serves as both a repository and a backup for my Virtual Server (or Virtual PC) images. Having your VHD image on a hard drive other than your system drive is essential for performance. This drie is particularly useful because I can use either firewire or USB to connect to any system. Using Maxtor’s software, I can also use this device to automatically backup files from any of my systems too — and literaly at the touch of a button!

external hard drive

The Bluetooth Headset

On occassion, depending on the room setup, I can use this Motorola headset in place of a mobile mic. I pair the headset with my laptop and use the mic to output to my speakers at a podium. If I bend the podium mic to the speakers, I have a virtual walking mic. Obviously if a mobile mic is available, I use that instead for better clarity.

bluetooth headset

The Tablet PC

You may be asking why I use both a laptop and this new Gateway Tablet PC. Actually, this makes great sense if you ask me. I can set up the tablet as a sort of teleprompter during my presentations. The tablet can hold my demo scripts and walkthroughs (in case I lose a bolt during the presentation and need to remember where I’m at). Also, I didn’t buy the top of the line tablet. While the 14″ widescreen LCD makes this item look expensive, I only paid $1300 for this one — and that’s standard pricing. It only has 512 MB of ram, but thats all I need for my tablet PC needs — particularly when doing presentations. This tablet has a directional mouse-like input device on the left hand side that allows me to easily scroll up and down in my document without using the stylus.

tablet PC

The Thumbdrive

While I do have wireless connections, bluetooth and infared that can share data, I prefer to use the tumbdrive for quick transport between the laptop and the tablet when neccessary. I also carry a copy of the presentation materials on it in case someone asks me for them. Then its as easy as plugging the thumbdrive into their machine and letting them drag them onto their desktop.


The Smartphone

I use the smartphone to help keep my timing in presentations. I leave the phone clipped to my belt and set up vibrating reminders to tell me when I should be at a certain point in my presentation. If I’m not there, I can speed things up. If I’m off to the races, I can slow things down and take a few extra questions when needed. I wouldn’t recommend buying one of these if you just want it for these purposes. I just happened to already have this phone so its what I use.


I love my tools. Its taken me a little while to learn what works and what doesn’t. I would imagine what works for one person wont neccessarily work for another. Let me know what you think.

Charleston Code Camp: Saturday September 17th

OK guys and gals. Some pretty big names are rolling into Charleston on Saturday, September 17th to present, free of charge, all those fancy topics we love to yap about so much. This is Charleston’s first code camp. Chris Williams tells me that enrollment is low. What would it take to persuade a few more folks to take a nice weekend trip to a college/beach town, watch some cool technology in a demonstration and go have a few drinks?

Check out the sessions and the speakers. If you don’t find anything you are interested in, come anyway and enjoy the beach with your fellow geeks! Please register quickly!

.NET Code Access Security – The fast version

I spoke at this months GSP Developers Guild meeting as the “short presenter”. We typically have two presentations each month — one is a short presentation and one is a long presentation. I had to cut my Code Camp slides in half, but I managed to only overrun a 30 minute presentation by say, 15 minutes 🙂 Glen Gordon was our “long presenter” today. He gave a great presentation on ASP.NET Mobile Controls. I knew the presentation material, but its always great to see people respond to the technology like they did. Glen is a beast — he gave a 4 hour long presentation at the Greenville MSDN event today too. From 1pm to 5pm today he discussed Web Services, SQL Server 2005 with end point registration, Infopath consumption of the web services and end points, ClickOnce deployment and more. He then took a quick drive over to the guild meeting to give another hour-long talk on mobile web development. It was a geek decathalon!

Thanks for the great day guys. I had a blast giving my presentation again. And I really enjoyed watching your presentations again Glen.