• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

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
0
bbdesign
Asked:
bbdesign
  • 3
  • 3
1 Solution
 
Michel PlungjanIT ExpertCommented:
Why alert? Insert it on the page instead in a bold red header
0
 
bbdesignAuthor Commented:
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.
0
 
dxdinhCommented:
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bbdesignAuthor Commented:
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.
0
 
Michel PlungjanIT ExpertCommented:
Your page loads fine in Fx 3.6 on Mac
I suggest you add the script like this:

EITHER just before the end body tag OR

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

0
 
bbdesignAuthor Commented:
Adding the window.onload and function seems to have fixed it! Thanks.
0
 
Michel PlungjanIT ExpertCommented:
YW :)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now