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