繁体   English   中英

适用于Donate Button Paypal的Javascript可在Chrome上运行,但无法在IE和Mozila上运行我的代码已附加?

[英]Javascript that works for Donate Button Paypal Working On Chrome But Not WOrking On IE And Mozila My Code Attached?

甚至没有在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上可以正常工作

谢谢

将表格附加到文档

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM