开发者

Truncate string in JavaScript

I have a url as string in javascript like follows :

http://localhos开发者_JS百科t:8080/Blah.ff?param=1&param=2...

I want to filter the string and get

?param=1&param=2....

How can I do this in javascript?


var str= "http://localhost:8080/Blah.ff?param=1&param=2";
var str2 = str.substr(str.indexOf("?"), str.length);
alert(str2);

http://jsfiddle.net/praveen_prasad/a9XBe/1/


var urlstring = "http://localhost:8080/Blah.ff?param=1&param=2";
var querystring = '?' + urlstring.split('?')[1];

http://jsfiddle.net/ipr101/htUa3/


There are a lot of ways to do this. I would start with the window.location or location.href elements. Read up some more here:

http://www.w3schools.com/js/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜