Solved

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

Posted on 2010-11-09
7
456 Views
Last Modified: 2013-12-07
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
Comment
Question by:bbdesign
  • 3
  • 3
7 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34094862
Why alert? Insert it on the page instead in a bold red header
0
 

Author Comment

by:bbdesign
ID: 34095049
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
 
LVL 7

Expert Comment

by:dxdinh
ID: 34095068
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:bbdesign
ID: 34095486
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 34095581
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
 

Author Comment

by:bbdesign
ID: 34096255
Adding the window.onload and function seems to have fixed it! Thanks.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34097624
YW :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now