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

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -