JS功能无法正常工作 [英] JS Function wont work

查看:76
本文介绍了JS功能无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它可以在我的计算机上使用,但是每当我上传它时都无法使用.


It works on my computer but whenever i uploaded it it doesnt work.


<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
<style type="text/css">
<!--
.box {
    color: #060;
}
.box input { background-image: url(back.jpg);
             background-repeat: repeat-x;
             font-color: white;
             font-weight: bold;
             border: 1px solid black;

                   }


}
-->
</style>

<SCRIPT LANGUAGE="JavaScript">

    var testD=document.getElementById('display2').value;
    var testVar=document.getElementById('display').value;
     if(Number(testVar) > 50) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(10));
        testD = testVar;
    } else if(Number(testVar) > 45 && Number(testVar) < 51) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(9));
        testD = testVar;
    } else if(Number(testVar) > 40 && Number(testVar) < 46) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(8));
        testD = testVar;
    } else if(Number(testVar) > 35 && Number(testVar) < 41) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(7));
        testD = testVar;
    } else if(Number(testVar) > 30 && Number(testVar) < 36) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(6));
        testD = testVar;
    } else if(Number(testVar) > 25 && Number(testVar) < 31) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(5));
        testD = testVar;
    } else if(Number(testVar) > 20 && Number(testVar) < 26) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(4));
        testD = testVar;
    } else if(Number(testVar) > 15 && Number(testVar) < 21) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(3));
        testD = testVar;
    } else if(Number(testVar) > 10 && Number(testVar) < 16) {
        parseInt(testVar);
        parseInt(testD);
        testVar = (Number(testVar)+Number(2));
        testD = testVar;
    } else if(Number(testVar) > 5 && Number(testVar) < 11) {
        testD = testVar;
        testD++;
    } else {
        var testD = Number(testVar);
    }
    document.getElementById('display2').value=testD;
}
  </SCRIPT>
</HEAD>
<BODY>
Enter something in the box: <BR><P>
 <div class="box"> <font color=""> <input name="display" style="text-align: center; width: 50px;" value="">
  <input style="text-align: center; width:50px;; " value="0" name="display2">
  <input type="button" name="button" style=";" value="Click" onClick="calc()"></font></div>
</BODY>
</HTML>

推荐答案

您能否尝试从上载的位置清除所有不需要的历史记录/缓存/临时文件.
Could you plese try by clearing all the unwanted history/cache/temp files from the uploaded location.


看来您需要修复PRE块.一些注意事项:
  • 在脚本标签中,您应该输入type ="text/javascript".
  • 上载时,您可能使用的浏览器与Visual Studio使用的浏览器不同.您正在调试.
  • 我建议使用警报功能来帮助自己调试上传的版本.这将帮助您找出正在执行的代码并找出变量值.
Looks like you need to fix your PRE blocks. Some notes:
  • In your script tag, you should say type="text/javascript".
  • When you upload it, you may be viewing it with a different browser than that used by Visual Studio when you are debugging. That could account for the difference.
  • I recommend using the alert function to help yourself debug the uploaded version. That will help you find out which code is getting executed and you can figure out variable values.


这篇关于JS功能无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆