I am trying window.open with a URL with spaces:
var msg = 'Hello, world!'; var url = 'http://yoursite.com'; var link = 'http://www.twitter.com/share?text=' + msg + '&url=' + url; window.open(link);
Running this code will open a new window using http://twitter.com/share?text=Hello,%2520world!&url=http://yoursite.com .
What happens is that the space in msg is converted to% 20, then "%" is converted to% 25. As a workaround, I added:
msg = msg.replace(/\s/g, '+');
But are there any other characters that I need to track, or is there a better way around this?
nymo
source share