How do i encode url

Hi, can i ask how can i encode paramters in the url,because i am passing variables to other page and i want that the url will encoded or the value of paramter ,.i am using window.open.

Thank you in advance.

Hi jemz,

depending on what you are trying to achieve you will want either encodeURI() or [URL=“https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent”]encodeURIComponent()

See also: http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent

Hi pullo,

Thank you for the reply…so this is intended only for the query string as for encodeURI and encodeURIComponent?..but how can i encode if i have this kind of parameter

page.php?empid=4

now i don’t want the user know the empid is 4,is it possible to do some hash something like this

index.php?empid=%72566363363663d&

because i am afraid that if the user will change the url or something like he will guess and change this to no. 5 or any no… the new page will load and some information will be seen.

can you help me on this please.

Thank you :slight_smile:

Hi jemz,

Then you need some kind of authentication system in place.
A user should not be able to get at sensitive information by guessing a url.
Simple as that, I’m afraid.

Thank you pullo :slight_smile: