1 Replies - 603 Views - Last Post: 14 May 2013 - 05:22 PM

#1 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 431
  • View blog
  • Posts: 1,825
  • Joined: 30-April 10

window.location with get string

Posted 14 May 2013 - 05:09 PM

I have just realized that I have an error in my Javascript redirect for a Facebook application.

FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        // the user is logged in and has authenticated
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;

        //send user to play game
        window.location = window.location + "play.php";
        //above is the trouble code

    } else if (response.status === 'not_authorized') {
        // the user is logged in to Facebook, 
        // but has not authenticated
        login();
    } else {
        // the user isn't logged in to Facebook.
        login();
    }
});



Line 08 in the above code is the issue. It works fine if there are no get variables attached to the URL.
If there is a get variable in the URL it will just append play.php to the end over and over until it is stopped, and will not direct to the URL/play.php.

Here is the query I ran to find this issue.

I went to my URL and added ?r=22 at the end and it gave me this
?r=22play.phpplay.phpplay.phpplay.phpplay.phpplay.phpplay.phpplay.phpplay.phpplay.phpplay.php

My questions are:
Why is this happening?
What is the best way to fix this?

Facebook's bookmarks work via get strings it is of interest to me to understand what is going on here.

Thank you for your time.

Is This A Good Question/Topic? 0
  • +

Replies To: window.location with get string

#2 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 431
  • View blog
  • Posts: 1,825
  • Joined: 30-April 10

Re: window.location with get string

Posted 14 May 2013 - 05:22 PM

Ok, I just changed it to window.location= " URL " and it seems to work fine.

Is this going to come and bite me in the backside as soon as I turn around?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1