Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Using the createElement function provided in this answer this answer, which is necessary due to IE's brokenness with the name attribute on elements created normally with document.createElement:

function postToURL(url, values) {
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}

Using the createElement function provided in this answer, which is necessary due to IE's brokenness with the name attribute on elements created normally with document.createElement:

function postToURL(url, values) {
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}

Using the createElement function provided in this answer, which is necessary due to IE's brokenness with the name attribute on elements created normally with document.createElement:

function postToURL(url, values) {
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}
Changed to idiomatic javascript indenting (braces on same line, to avoid semicolon insertion)
Source Link
function postToURL(url, values){
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}
function postToURL(url, values){
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}
function postToURL(url, values){
 values = values || {};
 var form = createElement("form", {action: url,
 method: "POST",
 style: "display: none"});
 for (var property in values) {
 if (values.hasOwnProperty(property)) {
 var value = values[property];
 if (value instanceof Array) {
 for (var i = 0, l = value.length; i < l; i++) {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value[i]}));
 }
 }
 else {
 form.appendChild(createElement("input", {type: "hidden",
 name: property,
 value: value}));
 }
 }
 }
 document.body.appendChild(form);
 form.submit();
 document.body.removeChild(form);
}
added 152 characters in body
Source Link
Jonny Buchanan
  • 62.9k
  • 17
  • 147
  • 150

Using the createElement function provided in this answer, which is necessary due to IE's brokenIE's brokenness with the name attribute on elements created normally with document.createElement:

Using the createElement function provided in this answer, which is necessary due to IE's broken document.createElement:

Using the createElement function provided in this answer, which is necessary due to IE's brokenness with the name attribute on elements created normally with document.createElement:

Tidied function
Source Link
Jonny Buchanan
  • 62.9k
  • 17
  • 147
  • 150
Loading
added 28 characters in body
Source Link
Jonny Buchanan
  • 62.9k
  • 17
  • 147
  • 150
Loading
Source Link
Jonny Buchanan
  • 62.9k
  • 17
  • 147
  • 150
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /