我无法在Google Chrome中正确加载此示例代码;它加载一个空白页面。代码似乎有什么问题?
代码如下:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<body>
<script type="text/javascript">
var myString = “56.02 degrees centigrade”;
var myInt;
var myFloat;
document.write(“\“” + myString + “\“ is “ + parseInt(myString) +
“ as an integer” + “<BR>”);
myInt = parseInt(myString);
document.write(“\“” + myString + “\“ when converted to an integer equals “ +
myInt + “<BR>”);
myFloat = parseFloat(myString); document.write(“\“” + myString +
“\“ when converted to a floating point number equals “ + myFloat);
</script>
</body>
</html>
答案 0 :(得分:3)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<script type="text/javascript">
var myString = "56.02 degrees centigrade";
var myInt;
var myFloat;
document.write("\"" + myString + "\" is " + parseInt(myString) +
" as an integer" + "<BR>");
myInt = parseInt(myString);
document.write("\"" + myString + "\" when converted to an integer equals " +
myInt + "<BR>");
myFloat = parseFloat(myString); document.write("\"" + myString +
"\" when converted to a floating point number equals " + myFloat);
</script>
</body>
</html>
这就是我所看到的: