且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery的location.href使用值

更新时间:2022-05-01 18:08:31

如果在示例中未向URL添加任何内容,浏览器将假定它是相对URL,并以当前位置来源作为前缀(您的网站上的http://www.x-rayqa.co.uk ).如果该存储的链接位于同一服务器上,则需要确保服务器名称后的路径正确.

If you don't add anything to the URL in your example, the browser assumes it's a relative URL and prefixes it with the current location origin (http://www.x-rayqa.co.uk on your site). If that stored link is on the same server, you'll need to ensure the path is correct after the server name.

如果它不是本地的(即外部链接),则必须自己添加服务器和协议前缀,以使链接正常工作.还要查看window.location文档,这可能有助于清除某些内容.

If it's not local (i.e., an external link) then you'll have to add the server and protocol prefix yourself to make the link work. Take a look at the window.location documentation as well, which might help clear some things up.

https://developer.mozilla.org/zh- US/docs/Web/API/Window.location

您可以直接分配给window.location.href或使用window.location.assign().

You can assign directly to window.location.href or use window.location.assign().