Skip to content

Instantly share code, notes, and snippets.

@RyoSugimoto
Created February 5, 2016 09:34
Show Gist options
  • Save RyoSugimoto/22478f8ff86342e52856 to your computer and use it in GitHub Desktop.
Save RyoSugimoto/22478f8ff86342e52856 to your computer and use it in GitHub Desktop.
JSによるリダイレクトを行なう際、リダイレクト元での参照元情報や検索パラメータを、リダイレクト先にも正しく引き渡すサンプル。 http://qiita.com/1987yama3/items/5ff58b6195fe6c3f268b
if ( isMobileDevice()) {
var redirect_url = "http://example.com/sp/index.html" + location.search;
if (document.referrer) {
var referrer = "referrer=" + encodeURIComponent(document.referrer);
redirect_url = redirect_url + (location.search ? '&' : '?') + referrer;
}
location.href = redirect_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment