由于某些奇怪的原因,我的Facebook连接在我的应用程序中无法正常运行,在连接空白屏幕后它就会死掉。
我的脚本适用于浏览器,BlackBerry 10 webworks应用程序,BlackBerry Z10上的浏览器,Galaxy Tab,Playbook,甚至可以在电脑上运行正常,但不能在应用程序中自行运行。 我知道在BlackBerry 10上你需要在浏览器中禁用该应用程序,我试过但没有用。
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
function fboauthstart() {
var url = 'https://graph.facebook.com/oauth/access_token?client_id=' + facebookOptions.clientId + '&redirect_uri=' + facebookOptions.redirectUri + '&client_secret=' + facebookOptions.clientSecret + '&code=' + authCode;
$.ajax({
type: 'GET',
url: url,
success: function(data) {
var response = data;
var response = response.split('&');
var theAccessToken = response[0].split('=');
window.accessToken = theAccessToken[1];
fbfirstlinkcheck();
}
});
}
function startOAuth() {
var url = 'https://www.facebook.com/dialog/oauth?client_id=' + facebookOptions.clientId + '&redirect_uri=' + facebookOptions.redirectUri + '&scope=email,read_friendlists,user_online_presence,publish_stream,user_birthday,user_location';
childWindow = window.open(url, '_blank');
window.int = self.setInterval(function() {
var currentURL = childWindow.window.location.href;
var callbackURL = facebookOptions.redirectUri;
var inCallback = currentURL.indexOf(callbackURL);
if (inCallback == 0) {
window.clearInterval(int)
var code = childWindow.window.location.search;
code = code.split('code=');
code = code[1];
window.authCode = code;
childWindow.close();
setTimeout(function() {
fboauthstart();
}, 1000);
}
}, 1000);
}
我尝试用assign替换href,替换但也没有工作,然后在计算机上它不再起作用。
我尝试将window.open更改为window.location.assign,但这也无效。 有人有这方面的经验吗?
答案 0 :(得分:4)
你需要使用这个
window.location.replace("link.html");
答案 1 :(得分:0)
InAppBrowser插件“转换”javascript window.open函数。除了InAppWindow之外,它不会再返回Window对象。
您仍然可以通过执行远程脚本来轮询子窗口:
var win = window.open( "http://...." );
win.addEventListener( "loadstop", function() {
var loop = setInterval(function() {
win.executeScript(
{
code: "window.myData"
},
function( values ) {
alert(values[0]);
}
);
});
});