If Apache2 won’t serve your JavaScript file try…

I had an issue with Apache2 improperly serving a JavaScript file which I seem to have fixed by making sure the file was terminated with a new-line character… this was really hard to diagnose and resolve! The behaviour in Firefox was that the file just didn’t finish to download, whereas the Apache2 logs indicated a 200 result… I think it may have had something to do with automatic compression, which is a dark art that I do not understand (mumbles something about mod deflate…).

window.resizeTo( … )

See here:

  1. You can’t resize a window or tab that wasn’t created by window.open.
  2. You can’t resize a window or tab when it’s in a window with more than one tab.
  3. Also, even if you create window by window.open(…) it is not resizable by default …see 4.
  4. To make window created by window.open() resizable, you must open it with resizable feature
myExternalWindow = window.open("http://example.com", "myWindowName", "resizable");
myExternalWindow.resizeTo(500,500); //resize window to 500x500

Passing selected value into HTML select onchange handler

So you have a <select> element and you want to call a handler, but you need to pass the selected value to the handler because you have multiple instances of the same <select> and can’t access them by ID (because there is many, one of which will have the new selected value, but you don’t know which). The solution is to pass in the newly selected value, like this:

<select onchange='handle_change( this.value )'>

Easy-peasy!