p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   Javascript "alert()" acts modeless (http://p2p.wrox.com/showthread.php?t=3686)

cppman September 9th, 2003 04:24 PM

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!

stalker September 11th, 2003 08:40 AM

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

cppman September 16th, 2003 09:52 AM

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.


All times are GMT -4. The time now is 12:27 AM.

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