奇怪的HTML输出

时间:2016-03-21 05:51:27

标签: javascript html

当我打开html文件时,会出现一个奇怪的输出。

Phrase-o_Matic说:

  

它的全部意义何在?   还没有JS的IDE可以告诉我那里的错误吗?

我使用Atom作为我的文本编辑器。

守则 -

export class Application implements OnInit {
    ngOnInit() {
        window.onresize = this.onWindowLoadOrResize;
        this.onWindowLoadOrResize();
    }
    private onWindowLoadOrResize() {
      //TODO: your logic        
    }
}

3 个答案:

答案 0 :(得分:1)

两个错误:

1)'}'在结束后#34; html"标签

2)" var rand2 = Math.floor(math.random()* words2.length);",m必须像Math.random()一样大写。

下面的代码可以使用。

    <!doctype html>
<html lang="en">
<head>
  <title>Phrase-o-matic</title>
<meta charset="utf-8">
<style>
body {
  font-family: Verdana , Helvetica ,sans-serif;
}
</style>
<script>
function makePhrases() {
  var words1 = ["24/7" , "multi_Tier" , "30,000 foot","B-to-B","win-win"];
  var words2 = ["xyz","abcd","batch","retired","morning"];
  var words3 = ["super","shot","shake","Sunny"];

  var rand1 = Math.floor(Math.random() * words1.length);
  var rand2 = Math.floor(Math.random() * words2.length);
  var rand3 = Math.floor(Math.random() * words3.length);

  var phrase = words1[rand1] + " " + words2[rand2] + " " +words3[rand3];
  var phraseElement = document.getElementById("phrase");
  phraseElement.innerHTML = phrase;
}
window.onload = makePhrases;
</script>
</head>
<body>
  <h1>Phrase-o_Matic says;</h1>
  <p id="phrase"></p>
</body>
</html>

答案 1 :(得分:0)

您要写var rand2 = Math.floor(math.random() * words2.length);而不是var rand2 = Math.floor(Math.random() * words2.length);

答案 2 :(得分:0)

你有一个小写的&#39; m&#39;在Math rand2。这应该是大写的。