Avatar of Brad Bansner
Brad Bansner
 asked on

Page reload on form submission with Javascript alert stops page from rendering

In the attached HTML file... if you fill out this form, it points to itself for validation on the server side. If not all required fields are filled in, in the <head> area this is inserted:

<script language="javascript" type="text/javascript">
alert ("One or more required fields was not filled in, please answer all questions.");
</script>

The rest of the page is just HTML. In all browsers EXCEPT Firefox, this works fine and the form is redisplayed so the user can fill in the required fields. However, most of the time, in Firefox... I just get a blank white screen. The attached file is the page source when this happens. The code looks fine, but Firefox stops rendering the page for some reason. I can't get any other browser to do this, and it happens in both Windows and Mac versions of Firefox.

Any workaround for this? Thank you!

temp.htm
Web BrowsersJavaScript

Avatar of undefined
Last Comment
Michel Plungjan

8/22/2022 - Mon
Michel Plungjan

Why alert? Insert it on the page instead in a bold red header
Brad Bansner

ASKER
The alert gets people's attention. Although your comment may be accurate, it doesn't explain why this is happening in the first place. It shouldn't be a problem, and I have used this same technique for years on many websites, so its sort of a big concern for me.
dxdinh

If you use classic ASP then after the Response.Write ("<script> alert ('....')</script>")

do a Response.End
or if you set buffer = true the do the Response.flush
Your help has saved me hundreds of hours of internet surfing.
fblack61
Brad Bansner

ASKER
The response buffer controls what the server is sending to the client, but it has nothing to do with the actual final rendering of the page, does it? That wouldn't change the page source at all.
ASKER CERTIFIED SOLUTION
Michel Plungjan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Brad Bansner

ASKER
Adding the window.onload and function seems to have fixed it! Thanks.
Michel Plungjan

YW :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.