-1

我的名为 find 的 JS 函数破坏了代码。当我删除它时,JS 是有效的。功能中的两个警报都不起作用。这是代码。可能有点困惑,但重要的是 JS 中的 JS 函数和警报。

我正在使用 Notepad++,而 HTML 输出什么都不是。我想查看警报。

<html> 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">

        table.Ekim {table-layout:fixed;}
    table.Ekim td{text-align: left; vertical align:top;width:14.2%;height:20%}

</style>

<head>



<body>



<?php

   header('Content-type: text/html; charset=utf-8');


$doc = new DomDocument(); 
$site = 'http://www.etu.edu.tr/?q=tr/takvim'; 
$deneme ="ali";
$olay = array();
$tarih = array();


if (@$doc->loadHTMLFile($site)) {    

$items = $doc->getElementsByTagName('div');     

foreach($items as $item) {
    if ($item->getAttribute("class") == "takvim-olay"){  

            $str = $item->nodeValue;  

array_push($olay,utf8_decode($str));

    }

}

  $items = $doc->getElementsByTagName('div');    
foreach($items as $item) {
    if ($item->getAttribute("class") == "takvim-tarih"){  

            $str = $item->nodeValue;  


array_push($tarih,utf8_decode($str));

        }

    }

}


?>

<script type="text/javascript">

alert("start");

var olay = <?php echo json_encode($olay);?>; 
var tarih = <?php echo json_encode($tarih);?>;


function find(){
    for(var j = 0;j<tarih.length;j++){    

          if(tarih[j].indexOf("Ekim")!=-1)
          {     
            if(tarih[j].indexOf("-")!=-1)
            {
                var pieces=tarih[j].split(" - ");
                if (pieces[0] <= pieces[1])
                {
                    var a=pieces[0];
                    for(var i=0; i<((pieces[1]-pieces[0])+1); i++)
                    {
                        boolean ctrl = true;

            for(var f = 0 ; f<ekim[a].length ;      f++){
                if(ekim[a][f] == olay[j]){
                                ctrl = false;
                            }
                        }

                        if(ctrl){
                            ekim[a++].push(olay[j]);
                        }
                    }

                }
                else 
                {
                    //some occ
                }
            }
            else if (tarih[j].indexOf(",") != -1) 
            {
               pieces=tarih[j].split(", ");
               for(var i=0; i<pieces.length; i++)
               {
               boolean ctrl = true;

               for(var o = 0 ; o<ekim[pieces[i]].length;o++){
                if(ekim[pieces[i]][o] == olay[j]){
                    ctrl = false;
                }
               }

               if(ctrl){
                ekim[pieces[i]].push = olay[j];
               }

               }
            }
            else
            {
            boolean ctrl = true;
                for(var t = 0; t<ekim[tarih[j]].length;t++){

                    if(ekim[tarih[j]][t] == olay[j]){
                        ctrl=false;
                    }
                }
                if(ctrl){
                    ekim[tarih[j]].push(olay[j]);
                }

            }
          } 
        }

}


    alert("end");


</script>


</body>

</html>
4

1 回答 1

2

问题是

boolean ctrl = true;

这不是有效的 JavaScript。大概,你想要

ctrl = true;
于 2013-10-13T17:32:48.303 回答