0

我正在我的网站上工作并在 localhost WAMP 服务器上对其进行测试。我在我的主页上包含了一个 javascript,用于显示滑动的 facebook likebox(使用 mootools 框架)。javascript 在 Chrome、Firefox、IE9 上运行良好。但是,我在 Opera 上看不到幻灯片框。

添加我的 javascript 文件夹(首选项 -> 内容 -> Javascript 选项)后,我尝试调试错误,但出现以下错误。(一旦我将本地驱动器中的 javascript 文件包含到 Opera 内容扩展中,我就可以看到滑动的 facebook likebox,但我仍然无法找出问题所在。)

Uncaught exception: TypeError: Cannot convert 'm' to object
Error thrown at line 1, column 47082 in <anonymous function: bottom>(n, m) in http://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js:
    m.appendChild(n);
called from line 1, column 51362 in <anonymous function: inject>(n, m) in http://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js:
    a[m||"bottom"](this,document.id(n,true));
called from line 19, column 1 in <anonymous function: FBSideLike.init>() in http://localhost/Demola_Template/media/js/fb-sidelike.js:
    var box = new Element('div', {

这是我的 javascript 看起来和调用 mootools-yui-compressed.js

var FBSideLike = {};

FBSideLike.init = function() {

    var scr = $$('script[fbpage]');

    if (scr.length == 1) {
        scr = scr[0];
        var fbpage = scr.get('fbpage');
    } else {
        return;
    }

    var border = scr.get('bordercolor') || '3b5997';
    var image  = scr.get('image') || 'plain';
    var base   = scr.get('src').replace('fb-sidelike.js', '');

    var box = new Element('div', {
        id: 'fb-side-like',
        styles: {
            backgroundImage: 'url(' + base + 'fb-sidebar-' + image + '.png)',
            backgroundRepeat: 'no-repeat',
            position: 'fixed',
            top: '12%',
            right: -292,
            width: 322,
            height: 200
        }
    }).inject(document.body);

    var like = new Element('div', {
        styles: {
            position: 'absolute',
            left: 30,
            width: 292,
            height: 480,
            background: '#FFF'
        }
    }).inject(box);

    var toggle = function(dir) {
        box.tween('right', dir < 0 ? -1 : -292);
    }

    like.set('html', '<iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2F'
                    + fbpage
                    + '&amp;width=292&amp;height=480&amp;colorscheme=light&amp;show_faces=true&amp;border_color=grey'
                    + border
                    + '&amp;stream=true&amp;header=false&amp;appId=************"'
                    + 'scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:480px;" allowTransparency="true"></iframe>');

    box.set('tween', {
        duration: 550,
        transition: Fx.Transitions.Pow.easeInOut
    }).addEvents({
        'mouseenter': function() { toggle(-1); },
        'mouseleave': function() { toggle(1); }
    });
}

if (typeof(MooTools) == 'undefined') {
    (function() {
        var mt = document.createElement("script");
        mt.type = "text/javascript";
        mt.src = ("https:" == document.location.protocol ? "https" : "http") + "://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js";
        mt.async = true;
        mt.onload = FBSideLike.init;
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(mt, s);
    })();
} else {
    window.addEvent('load', FBSideLike.init);
}

在我的主页上,我包含了 javascript

<script type="text/javascript" src="media/js/fb-sidelike.js" fbpage='*******'></script>

查看错误消息,看起来问题出在 mootools-yui-compressed.js javascript 文件中。但是,我无法弄清楚出了什么问题,因为它在所有其他浏览器上都可以正常工作。这是浏览器特定的问题还是我遗漏了什么。

4

0 回答 0