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

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

问题描述

我的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 的一些文档

Here's some documentation for you for window.location.

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

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