小编lro*_*408的帖子

JavaScript函数在Firefox上运行良好但在Chrome上运行良好

我有一个javascript函数,点击按钮改变导航栏的颜色.我使用了验证器,它没有返回任何错误.我在两个浏览器上都使用了验证器.这是代码的一部分,任何建议将不胜感激.

<body class ="backgroundTwo">
        <h1 class ="centered sansSerif background" >Hello World!</h1>
        <div>
            <ul class ="center">
                <li class ="center"><a id="demo" class ="center"        href="about.html" >About This Site</a></li>
               <li class ="center"><a id ="demo2" class="center" href="current.html">Current Work</a></li>
               <li class ="center"><a id ="demo3" class="center" href="http://www.dallascowboys.com/">Cowboys</a><li>

            </ul> 
        </div>

        <h1 class = "centered" > <img src ="image.jpg" alt = "Cowboys" style="width:304px;height:228px;"></h1>
        <p class = "centered sansSerifTwo" >This is lrodrig6's CSC412 WebSite Project</p>
        <div class ="wrapper">
            <button class="button" onclick="colorFunction()">click    me</button>
        </div>
        <script>
            function colorFunction(){
             var color3 = document.getElementById("demo").style.backgroundColor; …
Run Code Online (Sandbox Code Playgroud)

javascript

3
推荐指数
1
解决办法
54
查看次数

冗余如果消息

我让我的Fraction程序运行顺利,但NetBeans IDE告诉我以下内容if是多余的:

public boolean equals(Object other)
{
  Fraction bool = (Fraction) other;

  if(this.numerator == bool.numerator && this.denominator == bool.denominator)
  {
   return true;
  }
  else return false;       
} 
Run Code Online (Sandbox Code Playgroud)

上面的代码编译/运行完美并传递了所有测试用例,但NetBeans的冗余标志真的让我感到烦恼.我添加reduceToLowestTerms()到我的代码,标志消失,但我已经reduceToLowestTerms()在我的构造函数中.这就是非冗余代码(根据NetBeans)的样子:

public boolean equals(Object other)
{
        Fraction bool = (Fraction) other;

        if(this.numerator == bool.numerator && this.denominator == bool.denominator)
        {
         bool.reduceToLowestTerms();
         this.reduceToLowestTerms();
         return true;
        }
         else return false;       
    } 
Run Code Online (Sandbox Code Playgroud)

任何建议将不胜感激

java netbeans

1
推荐指数
1
解决办法
149
查看次数

标签 统计

java ×1

javascript ×1

netbeans ×1