gpt4 book ai didi

javascript - 如何使用 jquery 或 javascript 获取基本 url?

转载 作者:IT王子 更新时间:2023-10-29 02:41:13 25 4
gpt4 key购买 nike

在 joomla php 中,我可以使用 $this->baseurl 获取基本路径,但我想在 jquery 中获取基本路径。

基本路径可以是以下任何一个示例:

http://www.example.com/
http://localhost/example
http://www.example.com/sub/example

示例 也可能发生变化。

最佳答案

我认为这很适合你:

var base_url = window.location.origin;

var host = window.location.host;

var pathArray = window.location.pathname.split( '/' );

关于javascript - 如何使用 jquery 或 javascript 获取基本 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25203124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com