我正在我的页面中开发一个 Facebook 应用程序 https://www.facebook.com/BLOWUPPARTYOFFICIAL/app_449233448431335
但页面不会向上滚动到顶部,并且页面不会调整大小(始终显示垂直滚动条)。
它适用于 Windows 上的 Chrome 和 Firefox,但我不知道为什么,它不适用于 Mac 上的 Safari、Chrome 和 Firefox。
我尝试将 Canvas 高度设置为流畅并“固定为 800 像素”,但没有任何变化。
我没有使用 SSL 证书,我使用的是 https://secure.social-server.com/v2/去做吧。这可能是问题所在吗?
这是尝试使用 FB.Canvas.scrollTo
和 FB.Canvas.setAutoGrow()
的多个页面之一的代码:
<body>
<?php
$id = $_GET['id'];
?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1&appId=449233448431335";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script type="text/javascript">
window.fbAsyncInit = function() {
//Your app id must be added there to work
FB.init({appId: 'xxxxxxxxxxxx', status: true, cookie: true, xfbml: true});
//Resize the iframe when needed
FB.Canvas.setAutoGrow(true);
FB.Canvas.scrollTo(0,0);
};
</script>
<br /><br /><br />
<div class="invia-box">
.......
这是 facebook javascript sdk 错误吗??
最佳答案
不是FB.Canvas函数的问题...
1) 另一个脚本在 Facebook 脚本之前导致错误。
2) 你的脚本声明不正确
尝试:
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'YOUR_ID', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
FB.Canvas.setAutoGrow(true);
FB.Canvas.scrollTo(0,0);
};
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
对我来说很好
关于javascript - FB.Canvas.scrollTo 和 FB.Canvas.setAutoGrow 适用于 Windows 但不适用于 Mac,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11015004/