0

甚至在 IE 上都没有显示任何错误,它在 Chrome 上工作正常,但在 Mozila 和 IE 上没有工作,我的代码是,

           <script type="text/javascript">
    function Donate()
{

    var myform = document.createElement("form");
    myform.action = "https://www.paypal.com/cgi-bin/webscr";
    myform.method = "post";
    myform.target = "_blank";

    var cmd = document.createElement("input");
    cmd.name = "cmd";
    cmd.type = "hidden";
    cmd.value = "_donations";

    var encrypted = document.createElement("input");
    encrypted.type = "hidden";
    encrypted.name = "business";
    encrypted.value = "mentorprotege2013@gmail.com";

    var lc = document.createElement("input");
    lc.type = "hidden";
    lc.name = "lc";
    lc.value = "US";

    var itemname = document.createElement("input");
    itemname.type = "hidden";
    itemname.name = "item_name";
    itemname.value = "mentor";

    var itemnumber = document.createElement("input");
    itemnumber.type = "hidden";
    itemnumber.name = "item_number";
    itemnumber.value = "2013";

    var note = document.createElement("input");
    note.type = "hidden";
    note.name = "no_note";
    note.value = "0";

    var currency = document.createElement("input");
    currency.type = "hidden";
    currency.name = "currency_code";
    currency.value = "USD";

    var bn = document.createElement("input");
    bn.type = "hidden";
    bn.name = "bn";
    bn.value = "PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest";

    var image = document.createElement("input");
    image.type = "image";
    image.src = "https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif";
    image.border = "0";
    image.id="Dimage";
    image.name = "submit";
    image.alt="PayPal - The safer, easier way to pay online!";

    //Most probably this can be skipped, but I left it in here since it was present in the generated code
    var pixel = document.createElement("image");
    pixel.border = "0";
    pixel.alt="";
    pixel.src = "https://www.paypalobjects.com/en_US/i/scr/pixel.gif";
    pixel.width = "1";
    pixel.height = "1";

    myform.appendChild(cmd);
    myform.appendChild(encrypted);
    myform.appendChild(lc);
    myform.appendChild(itemname);
    myform.appendChild(note);
    myform.appendChild(currency);
    myform.appendChild(bn);
    myform.appendChild(image);
    myform.appendChild(pixel);
    myform.submit();
}
    </script> 

希望您的建议在我的代码中没有错误,它在 chrome 上工作正常

谢谢

4

1 回答 1

1

将表单附加到文档

myform.appendChild(pixel);
document.body.appendChild(myform); //<-- Add this
myform.submit();
于 2013-01-22T13:28:23.913 回答