Closed
Bug 12021
Opened 25 years ago
Closed 24 years ago
Javascript prompt is returning bogus value
Categories
(Core :: XUL, defect, P3)
Tracking
()
VERIFIED
FIXED
M17
People
(Reporter: slogan, Assigned: danm.moz)
References
Details
(Whiteboard: [nsbeta2+])
The expected behavior (according to my Javascript book) -- on cancel, it should
return null. Otherwise, the string entered should be returned.
However I can't get this loop to work (it deals with all of the cases):
var value;
var done = false;
while ( done == false ) {
value = prompt( "Enter a value", "" );
dump( "value is " + value + "\n" ); // always prints nothing
if ( value== null )
done = true; // cancel should take me here, it doesn't
else if ( group == "" )
alert( "Please enter a value name" ); // I always get
here, even if data was entered
else
done = true;
}
As the comments indicate, regardless of what I enter or if I press ok or cancel,
I get "" as a rturn value.
In the previous bug report, "group" should be "value". Here is the modified
code:
var value;
var done = false;
while ( done == false ) {
value = prompt( "Enter a value", "" );
dump( "value is " + value + "\n" );
if ( value == null )
done = true;
else if ( value == "" )
alert( "Please enter a value" );
else
done = true;
}
Updated•25 years ago
|
Assignee: trudelle → danm
Comment 2•25 years ago
|
||
reassigning to danm. syd, why is this marked critical severity? Critical is
supposed to indicate crash, data loss or severe leak.
Looks to me like nsCommonDialogs aren't set up to catch the Cancel button and munge the response
appropriately. David?
Nope. The problem is in the DOM where it takes the cancel return value and
converts it into a empty nsString rather than returning the expected null
pointer. Of course you can't return a null pointer since the string is being
passed by reference ;) reassigning back to danm
Comment 5•25 years ago
|
||
mass-moving all m12 bugs to m13
BULK MOVE: Changing component from XUL to XP Toolkit/Widgets: XUL. XUL
component will be deleted.
Component: XUL → XP Toolkit/Widgets: XUL
Updated•25 years ago
|
Target Milestone: M16 → M17
Comment 8•25 years ago
|
||
Mass-moving all M16 non-feature bugs to M17, which we still consider to be
part of beta2
Assignee | ||
Comment 11•24 years ago
|
||
window.prompt() now returns a null JS value when the user punches "cancel".
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 12•24 years ago
|
||
*** Bug 43660 has been marked as a duplicate of this bug. ***
Comment 14•24 years ago
|
||
verified fixed -- 2000071810 mac/linux, 2000071910 win2k -- window.prompt()
returns null on cancel, and the string on OK (incl. "").
Status: RESOLVED → VERIFIED
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: jrgmorrison → xptoolkit.widgets
You need to log in
before you can comment on or make changes to this bug.
Description
•