0

I have a function in a floatbox like this:

parent.fb.resize( {left: -360, width: true, height:true }, function () {
    parent.location.reload( true );
}, 0.7 );

Ignore the fb.resize which is part of Floatbox. It's the callback function

parent.location.reload( true );

which I'm trying to improve upon. The function reloads the parent page from the server, and a PHP session variable controls the content of the parent page.

The problem I have is that the address bar only shows www.mywebsite.com/ so the user can't copy it as a link. Instead I would like it to show www.mywebsite.com/mypage.php?parameter=something. So I need the callback function to send the parameter with a GET, instead of relying on the seesion variable/ But, how?

user2226755
  • 12,494
  • 5
  • 50
  • 73
TrapezeArtist
  • 777
  • 1
  • 13
  • 38
  • 1
    find click or navigation events and make use of history.pushState({t: new Date().getTime()}, "page something", "/mypage.php?parameter=something"); check this answer: http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – num8er May 06 '16 at 22:08

1 Answers1

0

I solved it in the way num8er suggested. The callback function became

parent.window.history.pushState(null, null, "mypage.php?parameter=<?php echo $_SESSION['something'] ?>");
parent.location.reload( true );

Then because there are times when the session parameter has not been set, I expanded it to

<?php if (isset($_SESSION['something'])) { ?>
parent.window.history.pushState(null, null, "mypage.php?parameter=<?php echo $_SESSION['something'] ?>");
parent.location.reload( true );
<?php }else{?>
parent.location.replace( "http://www.mywebsite.com/mypage.php" );
<?php }?>
TrapezeArtist
  • 777
  • 1
  • 13
  • 38