首先让我说我在 web 服务器上的端口 80 上运行它,所以这不是这个代码不会在 internet explorer 上触发的原因。
此代码在 Firefox、Chrome 和 Safari 中完美运行。但是,当我尝试使用 Internet Explorer 运行它时,我只得到一个大的空白屏幕。
<link rel="stylesheet" type="text/css" href="styles/316127.css" />
<div id="fb-root"></div>
<div class="fb-login-button" data-show-faces="false" data-width="400" data-max-rows="1" scope="email,friends_work_history,friends_location,user_work_history,user_location" id="loginButton" style="display: inherit;"> </div>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<body>
window.fbAsyncInit = function () {
FB.init({
appId: 'MYAPPID', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
var form = document.createElement("form");
form.setAttribute("method", 'post');
form.setAttribute("action", 'FacebookLogin.ashx');
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", 'accessToken');
field.setAttribute("value", accessToken);
form.appendChild(field);
document.body.appendChild(form);
form.submit();
//display loading logo
document.getElementById('loadinggif').style.display = 'inherit';
document.getElementById('loginButton').style.display = 'none';
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
};
// 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));
<title>Test</title>
<form id="form1" runat="server">
<br />
<asp:Image ID="loadinggif" runat="server" ImageUrl="~/Site/ajax-loader.gif" ImageAlign="Middle" style="display: none;" CssClass="centered"/>
</form>
`