Category: "HTML / CSS"

The Back/Forward buttons

If you have post data, the browser will alert you on Back/Forward buttons. Sometimes, this is inconvenient. An option is to calculate the length of the GET string, and if it is within your tolerance, whatever that may be, change the form method to “GET".

Works great. Very little effort. Code includes dojo.


/* Check to see if you can create a get string of less than 255 characters */
var aInputs=('id_of_first_input','id_of_second_input','etc');
var l=aInputs.length;
for (i=0;i<l;i++)
	if (dojo.byId(aInputs[i]) != null)	
		sD+=aInputs[i]+'='+dojo.byId(aInputs[i]).value+'&';
if (sD.length < 255)
	frm.method='get';

* Within your tolerance refers to the fact that different browsers and servers may function … differently.