Perhaps you are trying to power your relay directly from the arduino? If it is, that might cause the arduino to reset. Disconnect your electronics from pin 5 and check with a multimeter the power switching. Note that if you use the browser back button, the previous page with its selection may be reloaded.