我不太了解javascript来弄清楚为什么这个脚本中以"window.open ..."开头的行在IE7-8-9b中抛出了无效的参数错误.在Firefox和Webkit中运行良好.
(该脚本onclick="share.fb()"使用html链接进行调用,并弹出一个新的浏览器窗口以在FB和Twitter上共享).
var share = {
fb:function(title,url) {
this.share('http://www.facebook.com/sharer.php?u=##URL##&t=##TITLE##',title,url);
},
tw:function(title,url) {
this.share('http://twitter.com/home?status=##URL##+##TITLE##',title,url);
},
share:function(tpl,title,url) {
if(!url) url = encodeURIComponent(window.location);
if(!title) title = encodeURIComponent(document.title);
tpl = tpl.replace("##URL##",url);
tpl = tpl.replace("##TITLE##",title);
window.open(tpl,"sharewindow"+tpl.substr(6,15),"width=640,height=480");
}
};
Run Code Online (Sandbox Code Playgroud)