Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将上一个URL传递到Javascript函数_Javascript_Jquery_Browser History - Fatal编程技术网

将上一个URL传递到Javascript函数

将上一个URL传递到Javascript函数,javascript,jquery,browser-history,Javascript,Jquery,Browser History,我基本上希望做的是有一个书签链接,当单击它时,它会对当前(或实际上是上一个)URL执行操作。我已经看到Youtube转换器等实现了这一点 我已尝试使用document.referer访问上一个URL,但无效 $(document).ready(function() { if(document.referrer.indexOf(window.location.hostname) != -1){ $referURL = document.referrer; console.

我基本上希望做的是有一个书签链接,当单击它时,它会对当前(或实际上是上一个)URL执行操作。我已经看到Youtube转换器等实现了这一点

我已尝试使用document.referer访问上一个URL,但无效

$(document).ready(function() {
  if(document.referrer.indexOf(window.location.hostname) != -1){
     $referURL =  document.referrer;
     console.log($referURL);
  }
});

什么不起作用?我刚才给你看的代码