You're here: Snippet Directory » HTML/JavaScript (65)
Language:

METHOD=POST redirector

Language: English
Programming Language: JavaScript
Published by: newcumdb [not registered]
Last Update: 5/15/2006
Views: 364


Description

This redirects a method=GET to a method=POST, allowing you to bookmark pages that have been retrieved via a form submission via POST.For a quick example, put the code below in an html page on a www server. Type the URL of the page into a browser and add this to the end of the URL: "?ssiittee=http://newsalert.com/bin/headlines&Query=linux".

Code

1 <!-- this changes requests from method=GET to method=POST --> 2 <!-- be sure to include ssiittee=http://..... in the request so we 3 know where to submit it to --> 4 5 <SCRIPT> 6 function parseQueryString (str) { 7 str = str ? str : location.search; 8 var query = str.charAt(0) == '?' ? str.substring(1) : str; 9 var args = new Object(); 10 if (query) { 11 var fields = query.split('&'); 12 for (var f = 0; f < fields.length; f++) { 13 var field = fields[f].split('='); 14 args[unescape(field[0].replace(/\+/g, ' '))] = 15 unescape(field[1].replace(/\+/g, ' ')); 16 } 17 } 18 return args; 19 } 20 </SCRIPT> 21 22 23 <SCRIPT> 24 var args = parseQueryString (); 25 26 document.write("<FORM method=POST action='" + args["ssiittee"] + "'>"); 27 28 for (var arg in args) { 29 if (arg != "ssiittee") { 30 document.write("<input type='hidden' name='" + arg + "' value='" + 31 args[arg] + "'>" ); 32 } 33 } 34 35 document.write("</FORM>"); 36 37 document.forms[0].submit(); 38 </SCRIPT>

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS