Is your Javascript code for the Donate button functioning properly in Chrome but encountering issues in Internet Explorer and Firefox? See my attached code for troubleshooting

My code is working fine on Chrome without any errors, but it is not functioning properly on Mozilla and IE. Here is the script:


<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 = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0469616a706b7674766b7061636136343537446369656d682a676b69">[email protected]</a>";

    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!";

    //I have left this pixel element in the code even though it may be unnecessary
    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> 

I would appreciate any suggestions as there are no errors in my code when using Chrome.

Thanks

Answer №1

attach the form to the page

myform.append(pixel);
document.body.attach(myform); //<-- Include this line
myform.send();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to retrieve and modify a SilverLight UserControl’s property within my codebehind file?

Recently, I embarked on my journey of learning Silverlight by building a Silverlight application in Visual Web Developer 2008. Within the user control, I have a public property that I need to access in the ASPX codebehind page. Could anyone provide guidan ...

Node.js continually throwing 503 errors

After successfully installing and running Node.js for a while, I attempted to execute a standard Hello World program. The code snippet looked something like this: var http = require("http"); http.createServer(function (request, response) { response.w ...

"Converting an object to a JSON string using URLSearchParams: A step-by

I am currently working on a piece of code that retrieves all the input types from a form const form = document.querySelector('form'); const data = new URLSearchParams(new FormData(form).entries()); My main concern is how to convert the above ...

Issues have arisen with certain sections of the website following adjustments to the .htaccess file

I recently updated my website to include Pretty URL's by following the advice in this htaccess question. Options +SymLinksIfOwnerMatch RewriteEngine On RewriteBase / # Make sure all URLs have www. RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteR ...

Choose all or none of the items from the list with a single click - v-list-item-group

I am interested in incorporating Vuetify's v-list-item-group component into my Vue application. This list is intended to represent nodes that are related to a graph, allowing users to select none, some, or all of them and delete the selected nodes. T ...

Guide to generating a fresh array of objects by combining values from two arrays!

I'm having difficulties combining two arrays of objects (retrieved from blockchain data) into a new array based on the values of the objects. The aim is to extract the most recent interaction with a user. A simplified yet closely resembling represen ...

Change the name of "rows" in the findAndCountAll method of Sequelize

Is there a way to change the key name for result.row when utilizing findAndCountAll in Sequelize? For pagination purposes, I am implementing findAndCountAll. The data structure I receive is as follows: { "count": 8, "rows": [ { ...

Retrieving JSON information from a lone field in a MySQL table

I am currently working with a PHP REST Web service that is being accessed from JavaScript. Everything works fine when I run a MySQL SELECT statement to select text fields and then use json_encode to convert the returned array into JSON objects. However ...

The attribute "at" is not a valid property for an Array

As per the documentation on MDN Web Docs Array.prototype#at method, it should be a valid function. However, when attempting to compile in TypeScript, an error occurs stating that the method does not exist. public at(index: number): V { index = Math.floor ...

Tips for effectively utilizing a cart collection system

I am currently exploring how to utilize sessions for user tracking and updating my cart collection. Below is the code from my route.js file in an Express and Node application: app.post('/cart/:id', function (req, res) { if (!userKey) { ...

Discovering the value of a checkbox using jQuery and Ajax

I have a challenge with sending the state of multiple checkboxes on my page back to the database using ajax. While I am comfortable working with jquery and ajax for SELECT and OPTIONS elements, I am struggling to do the same for checkboxes and extracting t ...

Issue with formatting and hexadecimal encoding in JavaScript

I am currently developing a LoRaWAN encoder using JavaScript. The data field received looks like this: {“header”: 6,“sunrise”: -30,“sunset”: 30,“lat”: 65.500226,“long”: 24.833547} My task is to encode this data into a hex message. Bel ...

Enable the execution of a function only once a specific period of time has elapsed

Here's the scenario I'm dealing with: In a fun group chat with my friends, I created a giphy bot that responds to /giphy [terms] messages by posting the top result for those terms. However, my friends started abusing it by spamming the chat. To ...

Scroll the content within an iframe's page container

Is it possible to scroll the entire browser window to the top when clicking on a link inside the iframe I'm in? I have control over both the page container and the iframe. ...

"Here's a simple guide to generating a random number within a specified range

I have encountered a specific issue: Within an 8-column grid, I am attempting to randomly place an item with a random span width. While I have successfully managed to position the item and give it a random width, I am struggling with adjusting the width b ...

Configuring IP Whitelisting for Firebase Cloud Functions with MongoDB Cluster

What is the process for including my Firebase Cloud Functions in the IP whitelist of my MongoDB cluster? Error Message: ...

Keep retrieving information until the outcome becomes an empty array

I'm currently implementing the Selly API in my project and I've encountered an issue with fetching all products as the Selly API paginates the results. To overcome this, my approach is to fetch all products, store them in an array, and then outp ...

Is it possible to navigate directly to a route using hashRouter instead of BrowserRouter after building a react app with webpack?

Issue Encountered Upon running npm run dev, the application loads successfully and I can navigate to the defined route "/", where the component is displayed. However, when using npm run buildDev and attempting to manually access "/login", it returns a "can ...

Update not reflecting on global variable across all Phaser states

Whenever you are on the helm state and adjust the warp factor before pressing the engage button, it triggers the function engage which sends out the necessary data. Upon receiving this data, the server checks if the inertial dampeners are active or not, th ...

Extracting data from a text editor using React.js

Currently, I am using a Quill JS component, which is a text editor designed for React JS. I am thoroughly testing its features and functionalities. I have successfully created an editor with a toolbar. However, I am facing a dilemma. I am unsure of how to ...