javascript 在 ie8 中不工作

发布于 2024-11-06 09:05:09 字数 856 浏览 0 评论 0原文

我使用了 fb 脚本来增加画布的大小。这是代码..

<div id="fb-root"></div>

<script type="text/javascript">
    window.fbAsyncInit = function () {
        FB.init({ appId: '171963559525911', status: true, cookie: true, xfbml: true });
        FB.Canvas.setSize({ width: 1500, height: 1500 });
    };

    (function () {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
                    '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    } ());
</script>

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>

它适用于我测试过的所有浏览器(IE8 除外)。事实上在 IE9 中也能工作,但在 IE8 中却不能工作。

请建议我解决这个问题。

谢谢

I have used a fb script to increase a size of canvas. Here is the code..

<div id="fb-root"></div>

<script type="text/javascript">
    window.fbAsyncInit = function () {
        FB.init({ appId: '171963559525911', status: true, cookie: true, xfbml: true });
        FB.Canvas.setSize({ width: 1500, height: 1500 });
    };

    (function () {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
                    '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    } ());
</script>

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>

It is working in all browsers I've tested except IE8. In fact also working in IE9 but not working in IE8.

Please suggest me to solve the issue.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

末骤雨初歇 2024-11-13 09:05:09

这就是我用来扩展画布大小的方法,它适用于所有浏览器:

<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
<script type="text/javascript">
    FB_RequireFeatures(["CanvasUtil"], function()
    {
      FB.XdComm.Server.init("/xd_receiver.htm?v=2");
      FB.CanvasClient.startTimerToSizeToContent();
    });
    function onWindowResized(info)
    {
      var canvasInfoDiv = document.getElementById("CanvasInfo");
      var text = String.format("window ({0}, {1}), page ({2}, {3}), canvas({4}, {5}), scrollPos({6}, {7}), canvasPos({8}, {9})", 
        info.window.w, info.window.h,info.page.w, info.page.h,
        info.canvas.w, info.canvas.h,
        info.scrollPos.x, info.scrollPos.y,
        info.canvasPos.x, info.canvasPos.y);
      canvasInfoDiv.innerHTML = text;
    }
</script>

您还需要将 xd_receiver.htm 放在可公开访问的目录中。这是该文件的内容:

xd_receiver.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>cross domain receiver page</title>
</head>
<body>
    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2" type="text/javascript"></script>
</body>
</html>

编辑:

$(document).ready(function(){
  FB.init({appId:'your-app-id', status:true, cookie:true, xfbml:true});
  $(window).load(function(){
    FB.Canvas.setSize({height:1100});
  });
});

显然将高度设置为内容的高度。之前我有:

FB.Canvas.setSize({height:$('html').height()});

但IE似乎不喜欢那样。不应该显式设置高度#,但在这种情况下必须这样做。

This is what I use for extending the size of my canvas and it works in all browsers:

<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
<script type="text/javascript">
    FB_RequireFeatures(["CanvasUtil"], function()
    {
      FB.XdComm.Server.init("/xd_receiver.htm?v=2");
      FB.CanvasClient.startTimerToSizeToContent();
    });
    function onWindowResized(info)
    {
      var canvasInfoDiv = document.getElementById("CanvasInfo");
      var text = String.format("window ({0}, {1}), page ({2}, {3}), canvas({4}, {5}), scrollPos({6}, {7}), canvasPos({8}, {9})", 
        info.window.w, info.window.h,info.page.w, info.page.h,
        info.canvas.w, info.canvas.h,
        info.scrollPos.x, info.scrollPos.y,
        info.canvasPos.x, info.canvasPos.y);
      canvasInfoDiv.innerHTML = text;
    }
</script>

You need to have the xd_receiver.htm inside of a publicly accessibly directory as well. Here is the contents of that file:

xd_receiver.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>cross domain receiver page</title>
</head>
<body>
    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2" type="text/javascript"></script>
</body>
</html>

EDIT:

$(document).ready(function(){
  FB.init({appId:'your-app-id', status:true, cookie:true, xfbml:true});
  $(window).load(function(){
    FB.Canvas.setSize({height:1100});
  });
});

Obviously set the height to whatever the height of your content is. Before I had:

FB.Canvas.setSize({height:$('html').height()});

But IE seems to not like that. Shouldn't have to explicitly set the height #, but had to in this case.

风透绣罗衣 2024-11-13 09:05:09

让我们试试这个:


$.ajax({

  url: document.location.protocol +'/connect.facebook.net/en_US/all.js',

  dataType: 'script',

  success: function(){//do anything ...}

});

Lets try this one:


$.ajax({

  url: document.location.protocol +'/connect.facebook.net/en_US/all.js',

  dataType: 'script',

  success: function(){//do anything ...}

});

贱人配狗天长地久 2024-11-13 09:05:09
(function () {
        //doing stuff
    } ());

应该是

(function () {
        //doing stuff
    })();
(function () {
        //doing stuff
    } ());

should be

(function () {
        //doing stuff
    })();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文