在当前窗口中减去域名的简单方法是什么? [英] What's an easy way to get the url in the current window minus the domain name?

查看:37
本文介绍了在当前窗口中减去域名的简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Javascript不太热门,因此在进行一些凌乱的字符串操作之前,我想我会问:

My Javascript ain't so hot, so before I get into some messy string operations, I thought I'd ask:

如果当前网址为:"http://stackoverflow.com/questions/ask"

If the current url is: "http://stackoverflow.com/questions/ask"

什么是获取"/questions/ask"的好方法?

What's a good way to to just get: "/questions/ask" ?

基本上,我想要一个与Url匹配的字符串,但不包含域或"http://"

Basically I want a string that matches the Url without the domain or the "http://"

推荐答案

alert(window.location.pathname);

为您提供了一些 window.location 文档代码>.

这篇关于在当前窗口中减去域名的简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆