The ability to install a Firefox package, or any package really, that is old is totally dependent on what's available in your repositories and whether you have any cached installers lying around.
The method you're describing conforms to the requirements of the previous statement - you need to have a repository with the specified version in its contents, and in the specific release you are on. In most cases of old software, this is not the case, so you have to end up doing manual downloads of older package versions and install.
As Firefox 22 is sufficiently old that it might not exist anymore in the repositories for modern releases, and may even exist without the ability to recover it from the remote repository servers, you may have to manually download the Firefox package and manually install it.
For Firefox 22, you can use the following commands. Note that this will completely remove your much newer Firefox version, and will REPLACE your Firefox. It is also entirely possible that apt-get
and update manager will attempt to upgrade the version as well, and you will need to check to make sure Firefox is not upgraded.
For 64-bit Ubuntu:
sudo apt-get purge -y firefox
mkdir /home/$USER/firefox-old-binaries
cd /home/$USER/firefox-old-binaries
wget -O firefox_22.0+build2-0ubuntu0.12.04.2_amd64.deb https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa/+build/4751637/+files/firefox_22.0%2Bbuild2-0ubuntu0.12.04.2_amd64.deb
sudo dpkg -i firefox_22.0+build2-0ubuntu0.12.04.2_amd64.deb
For 32-bit Ubuntu:
sudo apt-get purge -y firefox
mkdir /home/$USER/firefox-old-binaries
cd /home/$USER/firefox-old-binaries
wget -O firefox_22.0+build2-0ubuntu0.12.04.2_i386.deb https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa/+build/4751640/+files/firefox_22.0%2Bbuild2-0ubuntu0.12.04.2_i386.deb
sudo dpkg -i firefox_22.0+build2-0ubuntu0.12.04.2_i386.deb