Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 9th, 2003, 04:24 PM
Registered User
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript "alert()" acts modeless

Using the following Javascript code (on Linux) produces different results depending on the browser. This code is closely related to that on page 14 of "Beginning Javascript" by Paul Wilton.



    <P>Paragraph 1</P>

    <SCRIPT LANGUAGE="JavaScript">
        alert ("First Script Block");

    <P>Paragraph 2</P>

    <SCRIPT LANGUAGE="JavaScript">
        alert ("Second Script Block");

    <P>Paragraph 3</P>



When using Netscape (Linux), it does not halt at the "alert()" as it should (alert() should invoke a MODAL message box), but instead rushes along until it completes all the Javascript code, leaving all of the messageboxes on the screen, waiting for dismissal.

When using Konqueror, it halts correctly at the "alert()", but never changes colors, staying the original GREEN.

If I change from "alert()" to "confirm()", the Netscape run works, but I want an "alert()", not a "confirm()",because this is a different user interface. The Konqueror version using "confirm()" still fails to change colors.

I would certainly appreciate some help if anyone is familiar with this. Thanks!
Old September 11th, 2003, 08:40 AM
Authorized User
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker

maybe netscape doesn't treat alert msg boxes as modal. check it at http://devedge.netscape.com
try to make a function that halts the script... but why do you want a script like that!? it doesn't do a thing at all! :)

good luck

Old September 16th, 2003, 09:52 AM
Registered User
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for your reply. netscape.com seems like a good place to look for this, since Netscape's compatibility is likely the issue here, rather than any fault with Javascript. However, I haven't found anything there yet.

The Javascript specification for the "alert()" function is that it activates a MODAL message box. To disregard this is to ignore the compatibility between browsers that the spec exists to provide. For Netscape to knowingly implement alert() as a modeless is unlikely. I suspect that it usually works correctly, but possibly there is a seemingly unrelated setting in Netscape that somehow causes this, and hopefully someone will share this here.

The purpose of alert() IS to halt the script, while the user is "alerted" to something. This is the definition of a modal message box. That is what it is there for, and there is no sense in hacking a "fix" that works for an aberrent browser, or a browser with goofy settings, but then causes trouble and irritation for the user with all other browsers.

The purpose of the "do nothing" script is to test the alert() function and the changing of background colors on different browsers, so that I can make a product that will work properly for any customer regardless what browser they use. What a radical concept! This is supposed to be standard operating procedure for all this web stuff, but unfortunately compatibility is often not achieved. Since it revealed this simple misfunction, then it clearly "did something".

Somewhere, someone knows the answer to this. And I am hoping they will find this and help.


Similar Threads
Thread Thread Starter Forum Replies Last Post
change text colors in an javascript Alert? larry Javascript How-To 5 February 12th, 2007 08:03 AM
PURE asp upload problem ., alert from Javascript kasanar ASP.NET 1.0 and 1.1 Professional 0 February 19th, 2005 10:06 AM
Javascript alert error Ed7777 Javascript How-To 5 June 25th, 2004 02:23 PM
Javascript alert box Adam H-W Javascript How-To 13 March 4th, 2004 05:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.