Added javascript code to handle alerts in Safari and make it work with all browsers