JavaScript Redirect based on Referrer?

前端 未结 1 1380
太阳男子
太阳男子 2021-02-05 23:46

Is there anyway to grab the referring URL using javascript, lets say the reffering url is http://page.com/home?local=fr, then redirect a user to a new page with the same local a

相关标签:
1条回答
  • 2021-02-06 00:16
    if (document.referrer != "") {
       var referringURL = document.referrer;
       var local = referringURL.substring(referringURL.indexOf("?"), referringURL.length);
       location.href = "http://page.com/login" + local; 
    }
    
    0 讨论(0)
提交回复
热议问题