Javascript history.PushState not working?

后端 未结 1 1574
滥情空心
滥情空心 2020-12-03 07:09

I have this code here:



        
相关标签:
1条回答
  • 2020-12-03 07:56

    The URL argument to pushState should be relative to the current page, or or an absolute URL in your own domain. You can't push state cross-domain - it would be a major security flaw.

    The MDN documentation says:

    The new history entry's URL is given by this parameter. Note that the browser won't attempt to load this URL after a call to pushState(), but it might attempt to load the URL later, for instance after the user restarts her browser. The new URL does not need to be absolute; if it's relative, it's resolved relative to the current URL. The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception. This parameter is optional; if it isn't specified, it's set to the document's current URL.

    The URL parameter is most commonly left blank or set a relative URL on your own site, like #/hello.

    0 讨论(0)
提交回复
热议问题