Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6700337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:48:08+00:00 2026-05-26T06:48:08+00:00

I’m opening a new window via a javascript POST in response to a user

  • 0

I’m opening a new window via a javascript POST in response to a user click in a flash application. The user may close the new window and want to re-open it by clicking the button on the first page again. Since I have to pass some large arguments to the second page, I have to do a POST, a GET won’t work. So far I have the second page opening and behaving correctly in Chrome, FF, and IE the first time the button is clicked. However, in Chrome (it works in IE and FF) the second time the button is clicked, the POST is ignored and the new window is not opened.

Here’s the function I use to do the POST. I have verified that it is making it all the way past the form.submit() line in Chrome with all the same parameters and no error notifications, but a new window still doesn’t open.

function post_to_url(path, paramString) {
    var params = paramString.split("|");

    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", path);
    form.setAttribute("target", "_blank");

    for (var i=0; i<params.length; i++) {
        var hiddenField = document.createElement("input");
        var param = params[i].split(":");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", param[0]);
        hiddenField.setAttribute("value", param[1]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
}

Any ideas on how this can be modified to get it to work in Chrome also?

Update:
It appears that the form isn’t removed from the DOM in Chrome. I’m not sure if that’s the issue or not, but it should be removed regardless.

We’ve also noticed that while 2nd POSTs in Chrome on Linux and Windows don’t go through, they do on Macs. However, even on a Mac the form isn’t removed from the DOM.

Another Update:
Altering the code like this correctly removes the form from the DOM, but it doesn’t solve the POST problem.

function post_to_url(path, paramString) {
    var postform = document.getElementById("postform");
    if (postform != null)
        document.body.removeChild(postform);
    var params = paramString.split("|");

    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", path);
    form.setAttribute("target", "_blank");
    form.id = "postform";

    for (var i=0; i<params.length; i++) {
        var hiddenField = document.createElement("input");
        var param = params[i].split(":");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", param[0]);
        hiddenField.setAttribute("value", param[1]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form);
    form.submit();
    var postform = document.getElementById("postform"); 
    document.body.removeChild(postform);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:48:08+00:00Added an answer on May 26, 2026 at 6:48 am

    I found a solution. Adding a random number to the end of the URL causes Chrome to run the POST multiple times. There must be a “feature” in Chrome that prevents multiple POSTs to the same URL.

    Here’s what I changed:

    form.setAttribute("action", path + '?' + Math.random().toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.