我怎样才能得到这份文件. 我是说,就像当前文件的推荐人一样.

我在我的网站上使用了Document.Referrer:

function statistics() {
  if(window.location.href.indexOf("statistics") > -1 && history.length) {
    history.back()
  } else if(window.location.href.indexOf("games") > -1 && history.length) {
    window.location.replace(document.referrer + "/../tournament.html");
  } else {
    window.location.replace("./tournaments/tournament.html");
  }
  }

这样做的目的是"记住"用户来自哪里.

现在,可以从该代码所在的站点转到设置站点.因此,所需的等效代码为:

function nftStatistics() {
  if(window.location.href.indexOf("statistics") > -1 && history.length) {
    history.go(-2)
  } else if(window.location.href.indexOf("games") > -1 && history.length) {
    window.location.replace(document.referrer.referrer + "/../tournament.html");
  } else {
    window.location.replace("./tournaments/tournament.html");
  }
}

然而,这段代码不起作用,因为Docent.ferrer.referrer不是一个东西. 我希望你能帮助我,想出一个解决方案,因为我一个人解决不了这个问题.

I have already tried

  1. Searching the Internet
  2. Searching the Internet for alternatives
  3. 问朋友

推荐答案

Solution个 不幸的是,出于隐私原因,这是不可能的,所以我只是在访问下一个URL时修改了URL.其代码如下所示:

function nftMarked() {
  if (window.location.href.indexOf("#statistics") > -1 && history.length) {
    window.location.replace("./nft.html#statistics=profile?=" + document.referrer);
  } else if (window.location.href.indexOf("#games") > -1 && history.length) {
    window.location.replace("./nft.html#games=profile?=" + document.referrer);
  } else {
    window.location.replace("./nft.html");
  }
}

返回到‘Docent.ferrer.referrer’现在看起来是这样的:

function nftStatistics() {
  if(window.location.href.indexOf("#statistics") > -1 && history.length) {
    history.go(-2)
  } else if(window.location.href.indexOf("#games") > -1 && history.length) {
    var url = String(window.location);
    url = url.split("=").pop();
    window.location.replace(url + "/../tournament.html")
  } else {
    window.location.replace("./tournaments/tournament.html");
  }
}

Conclusion个 如果你问我,这个解决方案不是那么干净,可以将你的用户转发到任何其他网站,如果他们编辑他们的URL,但这是唯一的解决方案,我想出来了.所以如果你有更好的主意,我会很高兴听到你的消息.

Javascript相关问答推荐

在Angular中将样式应用于innerHTML

如何解决chrome—extension代码中的错误,它会实时覆盖google—meet的面部图像?'

网页自检测外部元素无法加载

在react js中使用react—router—dom中的Link组件,分配的右侧不能被 destruct ''

我们如何从一个行动中分派行动

在grafana情节,避免冲突的情节和传说

JSDoc创建并从另一个文件导入类型

如何在ASP.NET中使用Google Charts API JavaScript将条形图标签显示为绝对值而不是负值

我怎么在JS里连续加2个骰子的和呢?

从页面到应用程序(NextJS):REST.STATUS不是一个函数

VSCode中出现随机行

使用父标签中的Find函数查找元素

删除元素属性或样式属性的首选方法

使用自动识别发出信号(&Q)

顶点图使用组标签更新列之间的条宽

为什么当雪碧的S在另一个函数中时,Phaser不能加载它?

输入数据覆盖JSON文件

当达到高度限制时,如何裁剪图像?使用html和css

在Reaction Native中,ScrolltoIndex在结束时不一致地返回到索引0

如何动态呈现适合未知屏幕大小的最大数量的表行?苗条的