I have a string of a url:
var url = "/_imgs/media/image/Picture%201.png"
When I try to split it lke:
var 开发者_StackOverflowpath = url.split('image/');
console.log(path);
gives:
["/_imgs/media/", "Picture%201.png"]
ok fine, but when I do
console.log(path[1]);
I get:
/Picture%png
What is happening here?
It looks like a problem with firebug rather than the javascript. Chrome displays the second console log fine, but firebug misses out the %20 (url encoded space).
Interestingly, if you try:
console.log(path[1].indexOf('2'));
You get 8
, which is the correct position. So the variable contains the right data, it's just the console showing it wrong.
精彩评论