Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: JScript Calling Window.prompt Cannot Handle DBCS Correctly


View products that this article applies to.

This article was previously published under Q244397

↑ Back to the top


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.

↑ Back to the top


Resolution

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>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-sjis">
<TITLE>HTML Sample</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function SbmtF()
{
	window.returnValue=document.InputForm.UserName.value;
	window.close();

}
</SCRIPT>
<BODY>
<FORM NAME="InputForm">
    <INPUT TYPE="text" NAME="UserName">
    <INPUT TYPE="button" NAME="btnSubmit" value="OK" onClick="SbmtF();">

</FORM>
</BODY>
</HTML>
				
The following is an example of how the preceding page can be used:
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-sjis">
<TITLE>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>

<BODY>

<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>
				

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Create an HTML page with the following code:
    <HTML>
     <BODY>
     <SCRIPT LANGUAGE="JavaScript">
       var first=window.prompt("YourName?:","");
       document.write("Mr. " + first + " welcome!<BR>");
     </SCRIPT>
    </HTML>
    					
  2. Activate the Japanese Input Method Editor (IME) and type a name using DBCS characters.
  3. Click OK.
Result:
You get "Mr." + [the name entered]. Notice that the word "Welcome" is missing.

↑ Back to the top


References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Keywords: kbbug, kbintl, kbintldev, kbpending, KB244397

↑ Back to the top

Article Info
Article ID : 244397
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 468