0

私は、訪問者がそのページの数式 (一種の wiki) を使用して変更できる Web ページを持っています。問題を引き起こすコードを以下に示します。このコードは正常に動作していましたが、コメントされているように見えるコード行 (jqueryreplaceWith呼び出し) を追加すると、ブラウザーは命令を正しく実行しますが、javascript/jquery コードを実行させるイベントにページが応答しなくなります。何が問題なのですか?

$(document).ready(function(){
  $("#envia").click(function(){
    objectiu = parent.frames[2].document.getElementById(parent.frames[2].id);
    substitut = '<H1>' + document.getElementById("txt1").value + '</H1>';
//  $(objectiu).replaceWith(substitut);
    $.post("xines.py",
    {
      tag: parent.frames[2].tag,            
      par: parent.frames[2].id,
      text: document.getElementById("txt1").value,      // TEXT
      codi: document.getElementById("txt2").value,      // COL·LABORADOR
      idioma: parent.frames[0].document.getElementById("txt3").value,   // IDIOMA
    },
    function(data,status){
      parent.frames[3].document.getElementById("myp").innerHTML= data;         
      parent.frames[2].document.getElementById(parent.frames[2].id).style.color='#000000';
      parent.frames[2].document.getElementById(parent.frames[2].id).innerHTML = document.getElementById("txt1").value;
      document.getElementById("txt1").value = "";
      document.getElementById("txt1").style.backgroundColor = '#FFFFFF';
    });
  });
});

Web ページの各要素には一意の ID があるため、ID が Web ページ内の複数の要素を参照することはできません。ID は次のようにフレーム 2 で割り当てられます。

$("p").click(function(){            // FUNCTION FOR CLICK ON <P>
    id = this.id;
    this.style.color = '#0000FF';
    parent.frames[1].document.getElementById("txt1").value = this.innerHTML;
    tag = this.nodeName;
    click_doc();
 });
$("h1").click(function(){           // FUNCTION FOR CLICK ON <H1>
    document.getElementById(id).style.color='#000000';
    this.style.color = '#0000FF';
    parent.frames[1].document.getElementById("txt1").value = this.innerHTML;
    tag = this.nodeName;
    id = this.id;
    click_doc();
 });
4

1 に答える 1

0
           objectiu = parent.frames[2].document.getElementById(parent.frames[2].id);
           substitut = '<' + noutag + ' id="' + bakid + '">' + text + '</' + noutag + '>';
           if (noutag!=parent.frames[2].tag) {
              $(objectiu).replaceWith(substitut);
           }
于 2014-01-01T23:43:18.673 に答える