20

After clicking a dynamic link in an email, my users land on a page with a form pre-populated like this:

http://www.test.com/november_promo/default.html?Name=Test&Email=Test.com

A script runs right at the beginning to re-direct them to a mobile version of the page:

<script type="text/javascript" src="redirection_mobile.min.js"></script>
<script type="text/javascript">
SA.redirection_mobile ({param:"isDefault", mobile_url: "www.test.com/november_promo/default_mobile.html", mobile_prefix : "http://", cookie_hours : "1" });
</script>

Is there any way to keep those parameters when they are redirected like that?

I know there are better ways to mobile-redirect with PHP, but my company's server is sketchy about letting my department's directory serve PHP files, so we try to do everything with Javascript.

Majid
14.3k16 gold badges81 silver badges117 bronze badges
asked Nov 8, 2011 at 19:11

1 Answer 1

35
document.location.search

can be used to append current location query strings to string in javascript

e.g.

<script>
var uri = 'foobar.html';
// while current location is 'baz.html?foo=1&a=b' for example
uri = uri + document.location.search;
// this will output 'foobar.html?foo=1&a=b' 
alert(uri);
</script>
answered Nov 8, 2011 at 19:14
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.