相关疑难解决方法(0)

window.open在IE7-8-9b中抛出无效参数

我不太了解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)

javascript internet-explorer javascript-events

13
推荐指数
1
解决办法
7711
查看次数