Microsoft KB Archive/244397

= BUG: JScript Calling Window.prompt Cannot Handle DBCS Correctly =

Article ID: 244397

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.5
 * Microsoft JScript 3.0
 * Microsoft JScript 4.0
 * Microsoft JScript 5.0
 * Microsoft Japanese Windows 95 1.0

-



This article was previously published under Q244397



SYMPTOMS
In some situations, such as the scenario described under "Steps to Reproduce Behavior" in the "More Information" section of this article, strings can be unexpectedly terminated when some part of the string is the result of a prompt dialog that had double-byte character set (DBCS) characters entered into it.

This only applies to the Japanese versions of Windows 95 and Windows 98.



Workaround:
To work around this problem, create your own prompt dialog, Prompt.htm. (Note that you will have to change the charset based on the language that you are targeting.)   HTML Sample  function SbmtF {   window.returnValue=document.InputForm.UserName.value; window.close;

}     

   The following is an example of how the preceding page can be used:  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-sjis"> HTML Sample</TITLE> <Script Language="JavaScript"> function btnConstant {   Title1 = "‚ "; strLink = Title1 + ">>Added String<<"; document.FM1.Text1.value = strLink; }

function btnAddLink_onclick {   Title1 = showModalDialog("prompt.htm"); strLink = Title1 + ">>Added String<<"; document.FM1.Text2.value = strLink;

} </Script>



<FORM name=FM1> <INPUT type="Text" size=80 value="" id=Text1 name=TextBox1> <INPUT type="button" value="Constant" id=btnAddLink name=btnAddLnk onClick=btnConstant><P>

<INPUT type="Text" size=80 value="" id=Text2 name=TextBox2> <INPUT type="button" value="Prompt" id=btnAddLink name=btnAddLnk onClick=btnAddLink_onclick><P>

</FORM> </BODY> </HTML>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> <li> Create an HTML page with the following code:   <SCRIPT LANGUAGE="JavaScript"> var first=window.prompt("YourName?:",""); document.write("Mr. " + first + " welcome!<BR>"); </SCRIPT> </HTML> </li> <li>Activate the Japanese Input Method Editor (IME) and type a name using DBCS characters.</li> <li>Click OK.</li></ol>

Result:

You get "Mr." + [the name entered]. Notice that the word "Welcome" is missing.

<div class="references_section">