Created
February 5, 2016 09:34
-
-
Save RyoSugimoto/22478f8ff86342e52856 to your computer and use it in GitHub Desktop.
JSによるリダイレクトを行なう際、リダイレクト元での参照元情報や検索パラメータを、リダイレクト先にも正しく引き渡すサンプル。
http://qiita.com/1987yama3/items/5ff58b6195fe6c3f268b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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