如何在Angularjs中获取网址引荐来源网址 [英] How to get Url referrer in Angularjs

查看:58
本文介绍了如何在Angularjs中获取网址引荐来源网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

页面中有一个按钮可以重定向到我的网站,由于我们无权访问页面重定向,我应该如何在angularjs中获取重定向到我的网站的页面URL

There's a button in a page that will redirect to my website, how should I get the page url that redirects to my website in angularjs since we don't have access to the page redirecting

$rootScope.$on('$locationChangeStart', function(evt:any, absNewUrl:any, absOldUrl:any):void {
     console.log('prev path: ' + absOldUrl);
  });

使用它可以给我们提供当前页面.

using this is giving us the current page.

ex:(testingPage.html应该重定向到myPage.html如何获取testingPage.html网址)

ex: (testingPage.html should redirect to myPage.html how to get testingPage.html url)

推荐答案

该页面应使用查询字符串访问您的网站.

The page should hit your website with a query string.

example.com 应该将您重定向到 yoursite.com/?ref=example.com ,这样您就可以从 $中提取查询变量location.search(); 的格式为 {'ref':'example.com'} .

example.com should redirect you to yoursite.com/?ref=example.com, then you would be able to extract the query variable from $location.search(); in the form of {'ref': 'example.com'}.

您可以在此处了解有关 $ location 的更多信息: https://docs.angularjs.org/api/ng/service/$location

You can read more about $location here: https://docs.angularjs.org/api/ng/service/$location

这篇关于如何在Angularjs中获取网址引荐来源网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆