Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why two string comparison not working? Need help!!

Status
Not open for further replies.

lipson

Technical User
Jul 23, 2010
2
US
Hi guys,

I place below script on my server, the value of a comes from url, the screen shows a=solar.barnard.columbia.edu:7777
but if statement always judges a=b is false, why?

Code as below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
document.write("Hello World!");
var url = window.location;
var a = document.URL.split("//"); // split at protocol
a = (a[1] ? a[1] : a[0]).split("/");
a=a[0];
b=("solar.barnard.columbia.edu:7777");
document.write(a);
document.write(b);
if (a==b){
alert("True");
} else {
alert("False");
}
</script>
</body>
</html>

Thanks in advance

yibing
 
Not sure, the code works fine for me.

If you can't stand behind your troops, stand in front of them.
Semper Fidelis

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top