不好意思,提问的不够好,先上源码
document.write('<iframe frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?url=%url%&appkey=&type=3" width="16" height="16"></iframe>'.replace(/%url%/, encodeURIComponent(location.href)));
一个分享微博的功能,我理解不了这句。
replace(/%url%/, encodeURIComponent(location.href))
/%url%/到底替换了什么?
/ 转义符为 %2F
% 转义符为 %25
所以
转义后等价于
location.href就是当前页面的链接,然后URI编码一下,整个的意思就是把iframe里的src的参数的第一个替换为url=当前链接的URI编码,例如,现在的页面: