We help IT Professionals succeed at work.

url has a bunch of params I want to hide

Tom Knowlton
Tom Knowlton asked
on
Is there a way to hide the params when I change to a new page?

  window.location.href = "coursesearch.aspx?storeid=" + storeid +
                "&termid=" + termid +
                "&deptid=" + deptid +
                "&courseid=" + courseid +
                "&sectionid=" + sectionid +
                "&storetext=" + storetext +
                "&termtext=" + termtext +
                "&depttext=" + depttext +
                "&coursetext=" + coursetext +
                "&addtocart=yes" +
                "&sectiontext=" + sectiontext;
Comment
Watch Question

Top Expert 2011
Commented:
Instead of placing them in the URL, you could create a form and use "method=post" - that way the values are accessible on the new page via Request.Form("parameter") rather than Request.QueryString("parameter")...

Of course, that means you need to update the new page to read values from form post.

Another method would be to place params in a cookie... then change the target page to read values from the cookie if you wanted to.  But, you'd need to update your target page to read from the cookie... and if you don't want the values to persist you would want to empty the cookie out right after you read the values so that subsequent form submissions would not accidentally pick up old values.
If it's supported by the back-end, you can use POST variables instead of GET variables. For that to work, you'd need to build a form on-the-fly with the appropriate parameters and automatically submit it:

var frm = document.createElement("form");
frm.action = 'coursesearch.aspx';
frm.method = 'post';

var parm1 = document.createElement("input");
parm1.type = 'hidden';
parm1.name = 'termid';
parm1.value = termid;

var parm2 = document.createElement("input");
parm2.type = 'hidden';
parm2.name = 'deptid';
parm2.value = deptid;

//etc...

frm.appendChild(parm1);
frm.appendChild(parm2);
document.body.appendChild(frm);

frm.submit();

Open in new window

Tom KnowltonWeb developer

Author

Commented:
thx