Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
function to redirect a webpage to another using post method
function redirect_by_post(purl, pparameters, in_new_tab) {
pparameters = (typeof pparameters == 'undefined') ? {}: pparameters;
in_new_tab = (typeof in_new_tab == 'undefined') ? true: in_new_tab;
var form = document.createElement("form");
$(form).attr("id", "reg-form").attr("name", "reg-form").attr("action", purl).attr("method", "post").attr("enctype", "multipart/form-data");
if (in_new_tab) {
$(form).attr("target", "_blank");
function(key) {
$(form).append('<input type="text" name="' + key + '" value="' + this + '" />');
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment