Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML和javascript未正确编译_Javascript_Html_Markup - Fatal编程技术网

HTML和javascript未正确编译

HTML和javascript未正确编译,javascript,html,markup,Javascript,Html,Markup,几周前,该代码似乎工作正常 然而,现在分支似乎完全中断了(浏览器类型没有什么意义) 有人知道为什么它可能不再工作了吗 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> &l

几周前,该代码似乎工作正常

然而,现在分支似乎完全中断了(浏览器类型没有什么意义)

有人知道为什么它可能不再工作了吗

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Examples of Strings</title>

<script type="text/javascript">
//<![CDATA[
         <!-- hide me
         // get a name 
         var monkey = prompt("What's the monkey's name?","The monkey");

// declare some short strings
var demanding = " demands - no - insists upon receiving ";
var requesting = " nicely asks for the benefit of all ";
var tech = " a computer that won't crash, and a homemade browser!";   
var peace = " love for everyone and peace on earth.";
// construct some longer strings
var userRequest = "Do you want to hear what "+ monkey + " wants?"
var techy_monkey = monkey + demanding + tech;
var hippy_monkey = monkey + requesting + peace;
// make some fancy strings
var bold_tech = techy_monkey.bold();
var italic_hippy = hippy_monkey.italics();
var shouting_hippy= hippy_monkey.toUpperCase();
var red_bold_tech = bold_tech.fontcolor('red');
// stop hiding me -->
//]]>
</script>
</head>
<body>
<h1>Monkey Babbles</h1>
<script type="text/javascript">
//<![CDATA[
         <!-- hide me


var monkey_love = prompt("Do you love the monkey?","Type yes or no");
if (monkey_love == "yes")
    {
    alert("Welcome! I'm so glad you came! Please, read on!");
    var monkey_statement = prompt(userRequest,"Type yes or no");
        if (monkey_statement == "yes")
        document.writeln(italic_hippy + "<br>");
        break;
    }
    else if  (monkey_love == "no")
    {
    alert("Just giving you the heads up: the monkey hates you too");
    var monkey_statement = prompt("Do you want to hear what the monkey wants?","Type yes or no");
        if (monkey_statement == "yes")
        document.writeln(red_bold_tech + "<br>");
        break;
    }
    else if  (monkey_love == "Type yes or no")
    {
    alert("Do you just randomly click on dialog boxes?");
    var monkey_statement = prompt("Do you want to hear what the monkey wants?","Type yes or no");
        if (monkey_statement == "yes")
        document.writeln(shouting_hippy + "<br>");
        else {
        document.writeln("The monkey is pained by your general lack of interest")
        }
        break;
    }
    else 
    {
    alert("You make no sense to monkey");
    var monkey_statement = prompt("Do you want to hear what the monkey wants?","Type yes or no");
        if (monkey_statement == "yes")
        document.writeln(bold_tech + "<br>");
        break;
    }




// show me -->
//]]>
</script>
<p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
  </p>

</body>
</html>

字符串示例
//
//]]>
胡言乱语
//
//]]>


您不能在
if
子句中放入
break
语句。如果我正确地阅读了代码,您可以简单地删除它们,一切都应该正常。

HTML和JavaScript永远不会编译。请检查您的JavaScript控制台(firefox中的shift-ctrl-J)并查找JavaScript错误。或者将If-else术语转换为switch语句;-)