No worries, I've fixed it. Moved the Javascript code down to the end of the code:<% ' Function to check if the sent code is the actual verification code Function isCode(enteredCode) ' Check if the entered code in caps is same as the session code (which is in caps) if UCase(enteredCode) = Session("image_ver") then ' Return true isCode = true else %><script language="javascript"> <!-- window.alert ("It looks like you entered the wrong code rnTry again or click 'Reload for another image' under the image."); window.history.go(-1); //--> </script><% 'Return False isCode = false end if End Function End If%>