Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.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
Javascript 浏览器后退按钮和上一页URL_Javascript_Url_Browser - Fatal编程技术网

Javascript 浏览器后退按钮和上一页URL

Javascript 浏览器后退按钮和上一页URL,javascript,url,browser,Javascript,Url,Browser,我有几个关于浏览器后退按钮的问题: 如何识别上一页的URL,通过该URL我可以访问当前页 如何确定所做的请求是针对浏览器历史记录中的上一页 我如何知道用户已单击浏览器的后退按钮 我们有一个要求,当用户在应用程序的某个点单击应用程序中的后退按钮时,他将返回到错误页面 必须通过Javasctipt实现。我尝试使用历史对象,但到目前为止,我被卡住了。请帮助我。您可以使用document.referer查看它们的来源。 还有一个很好的历史参考:1)如何识别上一页的URL,通过它我可以到达当前页 wind

我有几个关于浏览器后退按钮的问题:

  • 如何识别上一页的URL,通过该URL我可以访问当前页
  • 如何确定所做的请求是针对浏览器历史记录中的上一页
  • 我如何知道用户已单击浏览器的后退按钮
  • 我们有一个要求,当用户在应用程序的某个点单击应用程序中的后退按钮时,他将返回到错误页面


    必须通过Javasctipt实现。我尝试使用历史对象,但到目前为止,我被卡住了。请帮助我。

    您可以使用document.referer查看它们的来源。 还有一个很好的历史参考:

    1)如何识别上一页的URL,通过它我可以到达当前页

    window.document.referrer
    
    返回打开页面的url

    对于其他两个问题,以下是一个示例:

    Example
    
    Suppose http://mozilla.org/foo.html executes the following JavaScript:
    
    var stateObj = { foo: "bar" };
    history.pushState(stateObj, "page 2", "bar.html");
    This will cause the URL bar to display http://mozilla.org/bar.html, but won't cause the browser to load bar.html or even check that bar.html exists.
    
    Suppose now that the user now navigates to http://google.com, then clicks back. At this point, the URL bar will display http://mozilla.org/bar.html, and the page will get a popstate event whose state object contains a copy of stateObj. The page itself will look like foo.html, although the page might modify its contents during the popstate event.
    
    If we click back again, the URL will change to http://mozilla.org/foo.html, and the document will get another popstate event, this time with a null state object. Here too, going back doesn't change the document's contents from what they were in the previous step, although the document might update its contents manually upon receiving the popstate event.