用javascript分割网址 [英] Split url with javascript

查看:97
本文介绍了用javascript分割网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试拆分以下网址:

I'm trying to split following url:

http://www.store.com/products.aspx/Books/The-happy-donkey

只能 http://www.store.com/products.aspx

我正在使用javascript window.location.href并拆分但到目前为止还没有成功。
如何做到这一点?谢谢

I'm using javascript window.location.href and split but not success so far. How can this be done? thanks

推荐答案

试试这个

var fullurl = "http://www.store.com/products.aspx/Books/The-happy-donkey",
    url = fullurl.split(".aspx")[0] + ".aspx";

这篇关于用javascript分割网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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