甚至没有在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 = "[email protected]";

    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上可以正常工作

谢谢

最佳答案

将表格附加到文档

myform.appendChild(pixel);
document.body.appendChild(myform); //<-- Add this
myform.submit();

关于javascript - 适用于Donate Button Paypal的Javascript可在Chrome上运行,但无法在IE和Mozila上运行我的代码已附加?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14459588/

10-12 03:55