我有一个facebook应用程序,可以在所有其他浏览器上运行,但IE除外。以下是我的javascript代码:
(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));
window.fbAsyncInit = function() {
FB.init({
appId : '123456789', // App ID
channelUrl : 'http://test/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true // turn on oauth
});
// Additional initialization code here
};
function start() {
//send initial AJAX request
var bike_var = $("select#bike").val();
var reason_var = $("textarea#reason").val();
var dataString = 'bike='+ bike_var + '&reason=' + reason_var;
$.ajax({
type: "POST",
url: "save.php",
data: dataString,
success: function(data) {
//set ID in the form
$("input#recordID").val(data);
doLogin();
}
});
}
function doLogin() {
//Do request to Facebook to get user details and then post to wall and the submit the form
FB.login(function(response) {
if (response.authResponse) {
getUserInfo();
} else {
alert("Sorry! We can't enter you into the competition unless you allow our Facebook app!");
}
}, {scope: 'email, publish_stream'});
}
function getUserInfo() {
FB.api('/me', function(info) {
$("input#name").val(info.name);
$("input#email").val(info.email);
$("input#FID").val(info.id);
var params = {};
params['message'] = $("textarea#reason").val();
params['name'] = 'Test';
params['description'] = '';
params['link'] = 'http://www.facebook.com/ChainReactionCycles';
params['picture'] = 'http://crc.test/img/logo.gif';
params['caption'] = 'Test';
postToWall(params);
});
}
function postToWall(param) {
FB.api('/me/feed', 'post', param, function(wall) {
if (!wall || wall.error) {
} else {
document.forms["comp-entry"].submit();
}
});
}下面是启动代码的提交按钮的代码,目前正在所有其他浏览器中运行:
<input type="submit" name="submit_button" value="Enter Competition" onclick="start(); return false;">在IE中,这只会转到一个带有新记录的记录ID的空白页面,但是在我的数据库中,没有一个必需的facebook字段被填充。当我调试时,IE中的错误是'SCRIPT5002: Function‘。如果有人有任何想法,我将永远感激
发布于 2012-07-29 12:07:21
我的脚本上也有同样的错误信息,我在谷歌上搜索了错误代码,所以我无意中发现了你的问题。您的代码行(启动错误)帮助了我,所以我现在可以帮助您了。
显然,IE9不喜欢将"start“作为函数名。我的代码中有相同的函数,当我发现我自己的代码和您的代码之间存在冗余之后,我替换了函数名,et,瞧,现在一切都正常了。
https://stackoverflow.com/questions/9502125
复制相似问题