Depending on the trust you have with your boss, you might consider the radical idea (not for everyone or every situation) of talking to your boss BEFORE you accept an offer. Your level of security with this concept can range from gutsy (talk before putting resume on job search sites) to conservative (talk when offer letter is in hand, but before saying "yes"). But it doesn't always hurt to have the conversation of "I don't see what I want in the time I want it if I stay here... am I right?"
For the record, I actually had exactly that discussion with a former boss this year just before I left. Not only did he provide good thoughts at the time, but when I decided to leave the company he was a rock of stability in a very hard descision and we've kept up correspondence since.
If you don't feel comfortable with that, I say:
have a polite offer letter that you deliver in person with verbal notification first. You may even want to schedule a half hour on your boss' calendar so they have time to talk it over with you.
be ready to give MINIMUM 2 weeks notice, but if possible, be open to considerations. The company may or may not want more time from you - know what your new position can handle. Also- be aware of any huge balls in the air in your current assignments as you communicate with upcoming offers. It's commendable to lay out a time line with the new company that reflects a graceful hand off in the old place - it tells your new employers that you will extend the same courtesy to them shoudl you ever leave.
in the time remaining between resignation and departure - be a class act. Get any lingering commitments solidly completed OR train someone on the team to pick it up confidently. Figure out key areas you are the expert in and volunteer to do training. Don't take on new work - offer to mentor others. Avoid slacking off on the work, don't be late, continue to be engaged. In most healthy organizations, it's likely that you will not have useful work in the last few days, so make yourself present and available to be a sounding board for crises.
be aware of the resignation processes in your company - vacation time, health benefits, etc. - each company has their own rules about the weeks after you give notice.
hand in everything the company gave you. Be ahead of the curve - have a checklist that you vet with your boss so that you both agree that nothing got misses (laptops, USB sticks, books, cell phone, etc.)
work with your boss to identify and notify external groups you may work with. It may be that the boss wants to make this notification himself so he can manage the handoff - so be respectful of that.
send a nice, well thought out good bye letter on the last day. It's usually acceptable to provide personal contact information if you feel comfortable with that.
be sure to make personal contact with anyone you want to remain in touch with to exchange info (ie, don't just send your personal info and hope they write... ask for theirs and write yourself).
A smart boss will see that a departing person is not an enemy, but a future employee. If a smart person goes away and gets a great new job, then it's likely that they may be available in the future, with even more great experience. So a smart boss will not see it as a betrayal, but as a way to expand their own network.
The "Two Weeks"
In the US a common norm is to give 2 weeks notice - regardless of what's legally required by contract or by law in most positions, this is the standard for what's considered polite. Other countries have other norms, but I've noticed through Workplace threads, that there is quite often a norm for what's "abrupt" vs. "normal".
To address the comment thread that grew up around this answer - it's good, if possible to be ready and able to give the standard polite length notice. Don't put yourself deliberately into a position where this is absolutely impossible if you avoid it. Realize that mileage will vary remarkably, and it's hard to address a single unified rule here, there's only a few guidelines:
High risk, high security type positions - like system administrators, people working on highly classified work, or in particularly vital business areas may give the standard two weeks, and then be terminated THAT DAY. Quite often, when the company chooses to do this, it also chooses to pay those two weeks, but it isn't a given. Sadly, word of mouth may be the best way to find out if this is the standard in a given company.
Good reasons do count for something - provided they are real. Dramatic family problems that require relocation (very ill family member), once and a life time opportunities (getting cast on America's Next Top Model) - things like this can count with a good boss or a caring company - but realize that lying is just not that hard to discover, and lying about a reason for leaving to avoid giving two weeks won't make you look good.
Variations on the "I just don't want to stick around" don't count for much. Two weeks isn't all that long to wait - for either you or your new employer - and it can make a big difference to the hand off process. In a large enough company, it can even take 2 weeks to tell everyone that might want to know and say good bye to them. Cutting it short for a less than serious reason is somewhat remarkable and may well stick in the minds of those you work with as "he didn't care enough to give us two weeks to make sure we got his work covered". Not an impression that I would wish to leave on my fellow coworkers.
It's a courtesy, not a requirement. But saying "hey, it's not required, so I don't need to do it", is rather like foregoing most other social courtesies - no, you don't have to do them and skipping a few here and there makes you merely quirky. But this is the last impression of you. People remember. And it is more than just your boss who get affected here - you're part of a team, and the team wants to continue to do its work well after you leave.