javascript - window.location.href doesn't work in phonegap app - Stack Overflow

For some strange reason my Facebook connect does not work in my app in building, after it connect a bla

For some strange reason my Facebook connect does not work in my app in building, after it connect a blank screen it and it dies.

My script works in browser, BlackBerry 10 webworks app, browser on my BlackBerry Z10, Galaxy Tab, Playbook, even on the puter it works fine, but not in the app it self. I know on BlackBerry 10 you need to disable the app in browser, i tried but did not work.

<feature name="InAppBrowser">
  <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
    </feature>

function fboauthstart() {
    var url = '=' + 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 = '=' + 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);
}

I try to replace the href with assign, replace but also not worked and then on the puter it didn't work anymore.

I tried to change window.open to window.location.assign but also that did not work. Anyone have experience with this?

For some strange reason my Facebook connect does not work in my app in building, after it connect a blank screen it and it dies.

My script works in browser, BlackBerry 10 webworks app, browser on my BlackBerry Z10, Galaxy Tab, Playbook, even on the puter it works fine, but not in the app it self. I know on BlackBerry 10 you need to disable the app in browser, i tried but did not work.

<feature name="InAppBrowser">
  <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
    </feature>

function fboauthstart() {
    var url = 'https://graph.facebook./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./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);
}

I try to replace the href with assign, replace but also not worked and then on the puter it didn't work anymore.

I tried to change window.open to window.location.assign but also that did not work. Anyone have experience with this?

Share Improve this question asked Mar 7, 2014 at 10:40 АлександрАлександр 651 gold badge1 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You need to use this

window.location.replace("link.html");

InAppBrowser plugin "transforms" the javascript window.open function. It will not return a Window object any more but a InAppWindow.

You can still poll the children window, but by executing remote script:

var win = window.open( "http://...." );

            win.addEventListener( "loadstop", function() {
                var loop = setInterval(function() {
                    win.executeScript(
                        {
                            code: "window.myData"
                        },
                        function( values ) {
                            alert(values[0]);
                        }
                    );
                });
            });

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744509870a4577929.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信