JS代码在Firefox或Internet Explorer中不起作用

时间:2015-03-26 15:44:27

标签: javascript internet-explorer firefox

我想在网站上嵌入一个带有小型js-app的iFrame,但在FF和IE中,js不起作用(虽然它确实显示了html界面)。有办法解决这个问题吗? Chrome和Safari工作正常。

编辑:我最初没有发布任何代码,因为我认为可能有FF或IE的标准程序。 与此同时,我发现我的应用程序在FF或IE中无法正常运行...无赖。我遗漏了CSS,因为应用程序应该可以工作。它是债务转换的金融计算器。有什么想法吗?

    <html>
    <head>
        <title>title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">



      <style type="text/css">


*CSS Stuff*

        </style>


    </head>
    <body>

        <script language="JavaScript">
<!--

            var res = document.getElementById('r');



            function ersatzrate() {
                var zinsalt = document.test.zinsalt.value;
                var zeitalt = parseInt(document.test.zeitalt.value);
                var ratealt = parseInt(document.test.ratealt.value);


               StringText = zinsalt.toString();                       
               AusgabeText = StringText.replace(",",".");
               zinsalt=parseFloat(AusgabeText);



               var zinsneu = document.test.zinsneu.value; 

               StringText2 = zinsneu.toString();                      
               AusgabeText2 = StringText2.replace(",",".");
               zinsneu=(parseFloat(AusgabeText2)/100/12);

               zinsalt = zinsalt/100/12; 

                if (0.21 > zinsalt > 0 && 60 > zeitalt > 0 && 2000 > ratealt > 0 && zinsalt>zinsneu) {

                    var rkb = ratealt * zeitalt;               
                    document.test.rkb.value = rkb;

                    var bw = ratealt * ((Math.pow((zinsalt+1), zeitalt) - 1) / (Math.pow((zinsalt + 1), zeitalt) * zinsalt));  
                    var bw = bw.toFixed(2);
                    // document.test.bw.value = bw;

                    var rateneu =  bw*((Math.pow((zinsneu + 1), zeitalt) * zinsneu)/(Math.pow((zinsneu+1), zeitalt) - 1)); 
                    //rateneu = rateneu*1.01; 
                    var rateneu = rateneu.toFixed(2);                   
                    document.test.rateneu.value = rateneu;


                    var rkbneu = rateneu*zeitalt;
                    var rkbneu = rkbneu.toFixed(2);
                    document.test.rkbneu.value = rkbneu;


                    var ersparnis = (rkb-rkbneu);
                    var ersparnis = ersparnis.toFixed(2);
                    document.test.ersparnis.value = ersparnis;    
                }                               
            }
//-->
        </script>
        <div class="container">
        <form name="test">
        <fieldset>
            <legend><span class="number">1</span>title</legend>          

            <br><br>
            Old interest:<input onkeyup="ersatzrate()" type="text" name="zinsalt" value="8,00" size="10">
            time:<input onkeyup="ersatzrate()" type="text" name="zeitalt" value="36" size="10">
            old rate:<input onkeyup="ersatzrate()" type="text" name="ratealt" value="300" size="10"><br>
            <br>  
            <span class="number">2</span>New credit
            <br>
            <br>
            new interest:<input onkeyup="ersatzrate()" type="text" name="zinsneu" value="2,99" size="10"><br>
            <br>
            Neue monthly rate:  <output name="rateneu" ></output><br>    
            <br>
            <span class="number">3</span>Ersparnis                         
            cost of debt right now:  <output name="rkb"></output><br>  <br>
            cost new debt  <output name="rkbneu"></output><br>    
            <div align="right">
                   <br>
            _______
            </div>
            <br>


            <b>savings comparde to old debt: <output name="ersparnis"></output></b>
            </fieldset>
            </form>        
         </div>    



    </body>
</html> 

1 个答案:

答案 0 :(得分:0)

感谢F12调试器,不知道。

问题是在HTML中我没有指定“id = foo”,我只是指定了“name = foo”而Internet Explorer无法处理它。