我使用了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中没有工作。
请建议我解决这个问题。
由于
答案 0 :(得分:2)
这是我用来扩展画布大小的方法,它适用于所有浏览器:
<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似乎不喜欢这样。不应该明确设置高度#,但在这种情况下必须。
答案 1 :(得分:1)
让我们尝试一下:
$.ajax({
url: document.location.protocol +'/connect.facebook.net/en_US/all.js',
dataType: 'script',
success: function(){//do anything ...}
});
答案 2 :(得分:0)
(function () {
//doing stuff
} ());
应该是
(function () {
//doing stuff
})();