简体   繁体   English

JS文本解析器不起作用

[英]JS Text Parser Not Working

I wanted to make a text parser of sorts and I have done lots of research. 我想做各种各样的文本解析器,并且做了很多研究。

I was wondering if I am using javascript correctly. 我想知道我是否正确使用了javascript。 I know you shouldnt really make text parsers in js but it is the only scripting language of which I know. 我知道您不应该真正在js中进行文本解析器,但这是我所知道的唯一脚本语言。

Here is my code so far: 到目前为止,这是我的代码:

<script>
  function makeCode() {
    for (i = 0; i < userCode.length; i++) {
    if (userCode.substring("print:"(0, 6)) {
      document.write(usercode.substring("print:"(6,0));
  }
</script>

<style>
  p {
    text-align: center;
    color: #cc0000;
  }
  h1 {
    text-align: center;
    font-family: Impact;
    color: #cc0000;
  }
  body { 
    text-align: center;
  }
  form {
    text-align: center;
  }
</style>
<h1>NCPL</h1>
<p style="font-size: 10px">In Browser NinjaCorp Programming Language Editor</p>
</head>
<body>
<form name="userCode">
    <textarea id="userCode" name="userCode" cols="80" rows="20" placeholder="Type your code     here"></textarea></br>
    <a href="javascript:makeCode()"><button type="button">Run Code!</button></a>
</form>

Is this what you're looking for? 这是您要找的东西吗?

 function makeBode() { var userCode = document.getElementById('userCode').value; var myDiv = document.getElementById('myDiv'); // alert(userCode) for (i = 0; i < userCode.length; i++) { myDiv.innerHTML = myDiv.innerHTML + userCode.substring((i,i+6)) +'<br>'; } } 
 p { text-align: center; color: #cc0000; } h1 { text-align: center; font-family: Impact; color: #cc0000; } body { text-align: center; } form { text-align: center; } 
 <div id="myDiv"></div> <h1>NCPL</h1> <p style="font-size: 10px">In Browser NinjaCorp Programming Language Editor</p> </head> <body> <form name="userCode"> <textarea id="userCode" name="userCode" cols="80" rows="20" placeholder="Type your code here">Typing here so there is some text to work with </textarea></br> <a href="javascript:makeBode();"><button type="button">Run Code!</button></a> </form> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM