Prevent horizontal jumping with centered web pages

If you have a centered web page, you might have noticed ugly annoying jumping when you change between pages where some extend beyond the browser bottom and some don’t. This is of course caused by the simple fact that the vertical scroll bar appears and disappears depending on how long the page is.

Not a big deal, but I find it annoying. A simple fix is to simply always show the vertical scroll bar, which you can do with a tiny piece of CSS.

html
{
    overflow-y: scroll;
}

Problem solved.

JavaScript: Delayed keypress event (sort of)

Wanted to do an AJAX call whenever the content of a field was changed. This can be done simply with the onchange event, but the problem is that you have to tab out of the field to make it fire. You can also do it with the keypress event, but then you’ll get one AJAX call for each and every keypress, which is just silly.

Found a nice and easy solution, and here it is slightly simplified.

Continue reading