admin 管理员组文章数量: 1086019
i need to remove the first "/" in my url. As you can see my first value is correct, now i need to do the same to the second url. How can i delete the first "/"
option=_content&view=article&id=2&Itemid=2 < CORRECT
/option=_content&view=article&id=2&Itemid=2 < NOT GOOD FOR ME
i need to remove the first "/" in my url. As you can see my first value is correct, now i need to do the same to the second url. How can i delete the first "/"
option=_content&view=article&id=2&Itemid=2 < CORRECT
/option=_content&view=article&id=2&Itemid=2 < NOT GOOD FOR ME
Share
Improve this question
edited Jan 24, 2011 at 19:23
Zack The Human
8,4918 gold badges42 silver badges61 bronze badges
asked Jan 24, 2011 at 17:08
DeeDee
3,25510 gold badges38 silver badges40 bronze badges
6
- Where is the URL ing from? In what context is this? – Pekka Commented Jan 24, 2011 at 17:10
- What is the context? Where is the URL? In a variable? Link? – Felix Kling Commented Jan 24, 2011 at 17:10
- 5 14 of your questions are eligible for one of the answers to be accepted. You have currently accepted 0 answers. Please see stackoverflow./faq#howtoask for more information. – Andy E Commented Jan 24, 2011 at 17:17
- Is that really the correct url since it seems to be a / in a path and a querystring. Its possible that there is no query part and that what looks like that is actual the resource being pointed at but this seems unlikely... – Chris Commented Jan 24, 2011 at 17:19
- 1 I'm not sure if this question really has anything to do with jQuery -- is there a reason why it's called out in the title/tags? – Zack The Human Commented Jan 24, 2011 at 17:24
2 Answers
Reset to default 5Different way
var rawurl = "/option=_content&view=article&id=2&Itemid=2";
rawurl = rawurl.substr(rawurl.indexOf('/') + 1);
Try this -
var str = "/option=_content&view=article&id=2&Itemid=2";
str.replace(/\//, "");
Note: In this answer i have assumed you to save this part of url in variable str first.
本文标签: How to remove the first slash in my URL with JavaScriptStack Overflow
版权声明:本文标题:How to remove the first slash in my URL with JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744056624a2525969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论