梦之都
JavaScript教程
localeCompare
函数示例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>JavaScript localeCompare() 函数示例</title> </head> <body> <script type="text/javascript"> var str1 = "dreamdu"; var str2 = "reamdu"; document.write(str1.localeCompare(str2)); document.write("<br />"); str1 = "www.dreamdu"; str2 = "dreamdu"; document.write(str1.localeCompare(str2)); document.write("<br />"); str1 = "梦"; str2 = "都"; document.write(str1.localeCompare(str2)); </script> </body> </html>