parsing - URL Parse, write + redirect using Javascript -


my url arranged in following format.

http(s)://www.example.com/partner/retailer.aspx

(which think protocol+authority+path+file )

i parse, rewrite , redirect url when mobile device used.

for example:

http(s)://www.example.com/partner/retailer.aspx

would become

http(s)://www.example.com/details.aspx?p=retailer

so, /partner/ becomes /details.aspx , , file retailer.aspx converted query string p=retailer.

also, protocol of page (whether http or https) should preserved through redirect.

what easiest javascript way of doing this?

many thanks, james.

try this...

window.location = window.location.protocol + '//' +      window.location.hostname + '/' +      'details.aspx' +      '?p=' + window.location.pathname.split('.')[0] 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -