繁体   English   中英

java 脚本代码在 chrome 移动浏览器中不起作用,但在桌面上运行正常

[英]java script code not working in chrome mobile browser but in desktop its working fine

在我的 WordPress 网站中,我创建了 java 引导贷款计算器,它可以在桌面上完美运行,但是当我使用移动 chrome 时它无法正常工作。 我尝试使用 wp-coder 插件并尝试手动添加它。 在 chrome dev tools mobile 中查看它与真正的 devise 的工作正常。这个问题发生了。有没有办法解决这个问题我非常感谢你帮助解决这个问题

  <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css"
    />



        <div class="columns is-12-tablet is-6-desktop is-3-widescreen" style="height: 500px; width:100% " >
          <div class="column w-50 p-3 "  >
            <div class="card w-50 p-3">
              <div class="card-content w-50 p-3">
                <form id="loan-form">
                  <div class="level w-50 p-3">
               
                    <div class="level-left is-marginless w-50 p-3s">
                      <div class="level-item">
                        <p class="number">1</p>
                         <p> Loan Amount  &nbsp;&nbsp;&nbsp;</p>
                        <p id="yearssliderfuc">  </p>
                      </div>
                    </div>
                  </div>
          <input  id="amount"   type="range" min="20000" max="200000" step="10000"   onchange="yrthslide();computeResults()" />
                  <div class="level">
                    <div class="level-left is-marginless">
                    </div>
                    <div class="level-right">
                      <div class="level-item">
                        <div class="field">
                          <div class="control has-icons-right">
                            
                            <span class="icon is-small is-right">
                          
                              
                            </span>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="level">
                    <!-- Left side -->
                    <div class="level-left is-marginless">
                      <div class="level-item">
                        <p class="number">2</p>
                       <p> Number Of Days  &nbsp;&nbsp;&nbsp;</p>
                        <p id="monthssliderfuc">  </p>
                      </div>
                    </div>

                  </div>
           <input  id="years" min="30" max="120" step="30" type="range" onchange="monthslide();computeResults()" />
                  <div class="control">
          <br>
               
                  </div>
                </form>

              </div>
            </div>
      <div >
        <div class="notification is-link has-text">
          <p id="totalPayment" class="title ">LKR</p>
          <p class="subtitle is-4">Total Amount</p>
        </div>
      </div>
        <div >
          </div>    
        </div>


  


  <script >
function computeResults(e) {
  // UI

  const UIamount = document.getElementById("amount").value;
/*   var UIinterest = 50
  if(UIamount> 50){
    var UIinterest = 50
  }*/


  if(UIamount<50000){
    var UIinterest = 16/100;
  }else if(UIamount>50000 && amount<90000){
    UIinterest = 18/100;
  }else if(UIamount>100000 && amount<140000){
    UIinterest = 20/100;
  }else{
    UIinterest = 22/100
  }



  const UIyears = document.getElementById("years").value;





  var interestperday = (UIamount * UIinterest)/365;
  console.log(interestperday);
  console.log("interest per day");
  const monthly = parseFloat(interestperday);
  const monthlyPayment = monthly.toFixed(2);


  var interest = interestperday*UIyears;
  const interestfinalee = parseFloat(interest);
  console.log(interestfinalee);
  console.log("interest  all time");



  var ProFees =  (UIamount*10)/100;
  const ProFeesfin = parseFloat(ProFees);
  console.log(ProFeesfin);
  console.log("ProFees");

  var DocHFees = (UIamount*5)/100;
const DocHFeesfin = parseFloat(DocHFees);
  console.log(DocHFeesfin);
  console.log("DocHFees");

  var TransFee =  (UIamount*5)/100;
  const TransFeefin = parseFloat(TransFee);
  console.log(TransFeefin);
  console.log("TransFee");
  
  const UIamountfin = parseFloat(UIamount);


  // Calculating total payment
const all = TransFeefin + DocHFeesfin + ProFeesfin  + interestfinalee + UIamountfin
  console.log(all);
  console.log("allallallallallallallallallallallallallall");
///*****************************************************


  const totalPayment = all.toFixed(2);



  document.getElementById("totalPayment").innerHTML = "LKR " + totalPayment;

  e.preventDefault();
}


       
      function monthslide(){
            var Monthslider = document.getElementById("years").value
          document.getElementById("monthssliderfuc").innerHTML = Monthslider;
      }


             
      function yrthslide(){
            var Monthslider = document.getElementById("amount").value
          document.getElementById("yearssliderfuc").innerHTML = Monthslider;
      }
 
 
  </script>

您正在使用“computeResults()”function,但“computeResults()”function 未定义,“Calculate()”ZC1C425268E68385D14AB5074C17Z9 未使用。

更新:在代码更新后添加其他详细信息:

e.preventDefault() function 未定义并产生问题,我删除了它,它已经在移动设备中工作。

问题解决了。 它是因为相同的 function 名称在更改 function 名称后移动视图和桌面视图已解决

暂无
暂无

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

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