url has a bunch of params I want to hide

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;
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
AngryBinaryConnect With a Mentor Commented:
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

0
 
nap0leonConnect With a Mentor 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.
0
 
Tom KnowltonWeb developerAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.