title: AJAX page load/url with parameter causing blank page
body: <p>Good afternoon,</p>
  
  <p>I am working on a website for a friend's gaming fansite.  Utilizing a URI function and ajax URL loads, I'm setting it up so when they visit a page, the URL changes and that page's content loads, while leaving the top portion of the website static.  The logo, radio box and navigation bar is the static portion.</p>
  
  <p>Everything is working as intended so far, but when a page is used that's using a specific ID, it loads up a blank page.  I'll show what I've done with the Badges page for an example.</p>
  
  <p>Here's my <strong>HTACCESS</strong>:</p>
  
  <pre><code>Header set Access-Control-Allow-Origin *
  Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
  Header always set Access-Control-Allow-Headers "*"
  Options -MultiViews
  RewriteEngine On
  RewriteRule ^badges/([0-9]+)/?$ badges.php?id=$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [QSA,L]
  </code></pre>
  
  <p>Here's the <strong>URI</strong> script:</p>
  
  <pre><code>&lt;?php
    function getCurrentUri() {
        $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
        $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));
        if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?'));
        $uri = '/' . trim($uri, '/');
        return $uri;
    }
    $base_url = getCurrentUri();
    $routes = array();
    $routes = explode('/', $base_url);
    foreach($routes as $route) {
        if(trim($route) != '')
            array_push($routes, $route);
    }
    if ($base_url == "/" || $base_url == "/home") {
        $page = "home";
    } elseif ($base_url == "/about") {
        $page = "about";
    } elseif ($base_url == "/badges") {
        $page = "badges";
    }
  ?&gt;
  </code></pre>
  
  <p>Here's my <strong>AJAX</strong> call:</p>
  
  <pre><code>$(document).ready(function() {
          $.ajax({
              url: '&lt;?php echo $page; ?&gt;.php',
              success: function(content) {
                  $("#contfill").html(content);
                  history.pushState(null, '', '&lt;?php echo $page; ?&gt;');
                  homePageInit();
              }
          });
  });
  </code></pre>
  
  <p>When www.domain.com/badges is used, it loads the page correctly as shown here:</p>
  
  <p><a href="https://i.stack.imgur.com/hSIes.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hSIes.png" alt="Badge page working correctly"></a></p>
  
  <p>The first badge's ID is 324.  When www.domain.com/badges/324 is used, it loads the data correctly, but the page is blank as shown here:</p>
  
  <p><a href="https://i.stack.imgur.com/W85mH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W85mH.png" alt="Badge page not working correctly"></a></p>
  
  <p>Does anyone know why this would be?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I added in a alert('$base_url'); to see what it would be. When using www.domain.com/badges, it shows as /badges. When using www.domain.com/badges/324 no alert pops up, so it seems that it's going directly to badges.php. Is that due to the HTACCESS?</p>
  
  <p><strong>SECOND EDIT</strong></p>
  
  <p>Here is my <strong>badges.php</strong> script:</p>
  
  <pre><code>&lt;?php require('../panel/includes/config.php'); ?&gt;
        &lt;div class="row"&gt;
          &lt;div class="col-md-12"&gt;
            &lt;div class="panel panel-default"&gt;
              &lt;div class="panel-heading bg-color-blue"&gt;
                &lt;h3 class="panel-title"&gt;&lt;i class="fa fa-newspaper-o" aria-hidden="true"&gt;&lt;/i&gt; Badge Guides&lt;/h3&gt;
              &lt;/div&gt;
              &lt;div class="panel-body"&gt;
                &lt;p&gt;
                    &lt;img src="assets/images/1badge_guides.png" alt="Guides" class="img-responsive img-center"&gt;
                    &lt;?php
                      if (isset($_GET["id"])) {
                          $id = $_GET["id"];
                          $newsQuery = $dbh-&gt;prepare("SELECT * FROM news WHERE id=:id");
                          $newsQuery-&gt;execute(array(":id"=&gt;$id));
                          $newsQueryData = $newsQuery-&gt;fetch(PDO::FETCH_ASSOC);
                    ?&gt;
                    &lt;br&gt;
                    &lt;a href="https://twitter.com/share?url=http://habbfinity.ca/badge.php?id=&lt;?php echo $id; ?&gt;&amp;text=New badge guide posted!" class="btn btn-info"&gt;Tweet&lt;/a&gt;
                    &lt;br&gt;
                    &lt;?php
                          echo htmlspecialchars_decode($newsQueryData['article']);
                      } else {
                          $reqInfo2 = $dbh-&gt;prepare("SELECT n.id,
                                                         n.image,
                                                         n.title,
                                                         n.category,
                                                         n.description,
                                                         n.article,
                                                         n.active,
                                                         n.level,
                                                         n.available,
                                                         n.author,
                                                         n.stamp,
                                                         c.cat_num,
                                                         c.cat_name,
                                                         a.active_num,
                                                         a.active_name,
                                                         av.avail_num,
                                                         av.avail_name,
                                                         l.level_num,
                                                         l.level_name
                                                  FROM news n
                                                  INNER JOIN news_cat c
                                                      ON n.category = c.cat_num
                                                  INNER JOIN active_cat a
                                                      ON n.active = a.active_num
                                                  INNER JOIN avail_cat av
                                                      ON n.available = av.avail_num
                                                  INNER JOIN level_cat l
                                                      ON n.level = l.level_num
                                                  WHERE n.category = 10 AND n.active = 1
                                                  ORDER BY n.stamp DESC");
                          $reqInfo2-&gt;execute();
                    ?&gt;
                    &lt;p class="text-center"&gt;
                      &lt;strong&gt;BADGE GUIDES&lt;/strong&gt;
                    &lt;/p&gt;
                    &lt;table class="table table-striped"&gt;
                      &lt;thead&gt;
                        &lt;tr&gt;
                          &lt;th&gt;Badge&lt;/th&gt;
                          &lt;th&gt;Title&lt;/th&gt;
                          &lt;th&gt;Description&lt;/th&gt;
                          &lt;th&gt;Level&lt;/th&gt;
                          &lt;th&gt;Availability&lt;/th&gt;
                        &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                        &lt;?php
                          while ($reqInfoData = $reqInfo2-&gt;fetch(PDO::FETCH_ASSOC)) {
                        ?&gt;
                        &lt;tr class="bg-success"&gt;
                          &lt;td&gt;&lt;?php echo "&lt;img src=\"{$reqInfoData['image']}\" class=\"img-responsive\"&gt;"; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo "&lt;a href=\"#badge\" id=\"badge\" value=\"{$reqInfoData['id']}\"&gt;{$reqInfoData['title']}&lt;/a&gt;"; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $reqInfoData['description']; ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $reqInfoData['level_name']; ?&gt;&lt;/td&gt;
                          &lt;td&gt;
                            &lt;?php
                              if ($reqInfoData['avail_name'] == "Available") {
                                  echo "&lt;span style=\"color: green;\"&gt;{$reqInfoData['avail_name']}&lt;/span&gt;";
                              } else {
                                  echo "&lt;span style=\"color: red;\"&gt;{$reqInfoData['avail_name']}&lt;/span&gt;";
                              }
                            ?&gt;
                          &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;?php
                          }
                        ?&gt;
                      &lt;/tbody&gt;
                    &lt;/table&gt;
                    &lt;?php
                      }
                    ?&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>Here is the <strong>index.php</strong> page:</p>
  
  <pre><code>&lt;?php
    function getCurrentUri() {
        $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
        $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));
        if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?'));
        $uri = '/' . trim($uri, '/');
        return $uri;
    }
    $base_url = getCurrentUri();
    $routes = array();
    $routes = explode('/', $base_url);
    foreach($routes as $route) {
        if(trim($route) != '')
            array_push($routes, $route);
    }
    if ($base_url == "/" || $base_url == "/home") {
        $page = "home";
    } elseif ($base_url == "/about") {
        $page = "about";
    } elseif ($base_url == "/badges") {
        $page = "badges";
    }
    require('../panel/includes/config.php');
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;title&gt;Habbfinity&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/normalize.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/ie10-viewport-bug-workaround.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/custom.css"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="wrapper" class="container well"&gt;
        &lt;header&gt;
          &lt;section id="brand" class="row"&gt;
            &lt;div class="col-md-8"&gt;
              &lt;img src="assets/images/habbfinitylogo.png" alt="Habbfinity" class="img-responsive img-center"&gt;
            &lt;/div&gt;
            &lt;div class="col-md-4"&gt;
              &lt;div class="panel panel-default radpan"&gt;
                &lt;div class="panel-body"&gt;
                  &lt;?php
                    date_default_timezone_set('Europe/London');
                    $timecheck = date("H:00");
                    $timecheckwhour = strtotime($timecheck) + 60*60;
                    $newtimecheck = date("H:00", $timecheckwhour);
                    $daycheck = date("N");
                    $djQuery = $dbh-&gt;prepare("SELECT * FROM timetable WHERE day=:day AND time=:time");
                    $djQuery-&gt;execute(array(":day"=&gt;$daycheck, ":time"=&gt;$timecheck));
                    $djQueryData = $djQuery-&gt;fetch(PDO::FETCH_ASSOC);
                    if (isset($djQueryData) || $djQueryData != "") {
                        $djQuery2 = $dbh-&gt;prepare("SELECT * FROM users WHERE djname=:dj");
                        $djQuery2-&gt;execute(array(":dj"=&gt;$djQueryData['dj']));
                        $djQueryData2 = $djQuery2-&gt;fetch(PDO::FETCH_ASSOC);
                    }
                    $djQuery3 = $dbh-&gt;prepare("SELECT * FROM timetable WHERE day=:day AND time=:time");
                    $djQuery3-&gt;execute(array(":day"=&gt;$daycheck, ":time"=&gt;$newtimecheck));
                    $djQuery3Data = $djQuery3-&gt;fetch(PDO::FETCH_ASSOC);
                    if (isset($djQuery3Data) || $djQuery3Data != "") {
                        $djQuery4 = $dbh-&gt;prepare("SELECT * FROM users WHERE djname=:dj");
                        $djQuery4-&gt;execute(array(":dj"=&gt;$djQuery3Data['dj']));
                        $djQueryData4 = $djQuery4-&gt;fetch(PDO::FETCH_ASSOC);
                    }
                    $djSays = $dbh-&gt;prepare("SELECT * FROM dj_says ORDER BY id DESC LIMIT 1");
                    $djSays-&gt;execute();
                    $djSaysData = $djSays-&gt;fetch(PDO::FETCH_ASSOC);
                  ?&gt;
                  &lt;audio autoplay id="player"&gt;
                    &lt;source src="http://procyon.shoutca.st:8930/stream" type="audio/mp4"&gt;
                    &lt;source src="http://procyon.shoutca.st:8930/stream" type="audio/ogg"&gt;
                  &lt;/audio&gt;
                  &lt;form method="post"&gt;
                    &lt;p class="text-center"&gt;
                      &lt;button type="button" class="btn btn-trans" onclick="document.getElementById('player').play()"&gt;&lt;i class="fa fa-play galaxy" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
                      &lt;button type="button" class="btn btn-trans" onclick="document.getElementById('player').pause()"&gt;&lt;i class="fa fa-pause galaxy" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
                      &lt;button type="button" class="btn btn-trans" onclick="javascript:ajaxpage('requests.php', 'contfill');"&gt;&lt;i class="fa fa-comment galaxy" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
                      &lt;button type="submit" class="btn btn-trans" value="like" name="like"&gt;&lt;i class="fa fa-heart galaxy" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
                    &lt;/p&gt;
                    &lt;p&gt;
                      &lt;div class="row"&gt;
                        &lt;div class="col-md-3"&gt;
                          &lt;img src="https://www.habbo.com/habbo-imaging/avatarimage?hb=image&amp;user=augmented_Runes&amp;headonly=0&amp;direction=4&amp;head_direction=2&amp;action=wav&amp;gesture=&amp;size=m" class="img-responsive img-center"&gt;
                        &lt;/div&gt;
                        &lt;div class="col-md-9"&gt;
                          &lt;i class="fa fa-music" aria-hidden="true"&gt;&lt;/i&gt; &lt;span id="cc_strinfo_song_Habbfinity00" class="cc_streaminfo"&gt;&lt;/span&gt;
                          &lt;br&gt;
                          &lt;i class="fa fa-headphones" aria-hidden="true"&gt;&lt;/i&gt; &lt;span id="cc_strinfo_listeners_Habbfinity00" class="cc_streaminfo"&gt;&lt;/span&gt; Listeners
                          &lt;br&gt;
                          &lt;i class="fa fa-user" aria-hidden="true"&gt;&lt;/i&gt; &lt;span id="cc_strinfo_title_Habbfinity00" class="cc_streaminfo"&gt;&lt;/span&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="row"&gt;
                        &lt;div class="col-md-12"&gt;
                          &lt;p class="marquee2"&gt;
                            &lt;span&gt;&lt;?php echo $djSaysData['message']; ?&gt;&lt;/span&gt;
                          &lt;/p&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="row"&gt;
                        &lt;div class="col-md-12" style="margin-top: 20px;"&gt;
                          &lt;input id="vol-control" class="myrange" type="range" min="0" max="100" step="1" oninput="SetVolume(this.value)" onchange="SetVolume(this.value)"&gt;&lt;/input&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                    &lt;/p&gt;
                  &lt;/form&gt;
                  &lt;?php
                    if (isset($_POST['like']) &amp;&amp; isset($djQueryData2['habbo']) &amp;&amp; $djQueryData2['habbo'] != "") {
                        $dj = $djQueryData2['habbo'];
                        $ip = $_SERVER['REMOTE_ADDR'];
                        $cur_time = time();
                        $djLikes = $dbh-&gt;prepare("SELECT * FROM djlikes WHERE dj=:dj AND likedip=:ip");
                        $djLikes-&gt;execute(array(":dj"=&gt;$dj, ":ip"=&gt;$ip));
                        $djLikesData = $djLikes-&gt;fetch(PDO::FETCH_ASSOC);
                        if ($djLikesData['likedip'] != "") {
                            $lasttime = $djLikesData['lastliked'];
                            $diff = abs($cur_time - $lasttime);
                            if ($diff &gt; 3600) {
                                $AddLikes = $dbh-&gt;prepare("UPDATE djlikes SET likes = likes + 1 WHERE likedip=:ip");
                                $AddLikes-&gt;execute(array(":ip"=&gt;$ip));
                                echo "Thank you for liking the DJ!";
                            } else {
                                echo "Please wait an hour before liking the DJ again!";
                            }
                        } else {
                            $AddLikes = $dbh-&gt;prepare("INSERT INTO djlikes VALUES (:habbo, :time:, :ip, 1)");
                            $AddLikes-&gt;execute(array(":habbo"=&gt;$djQueryData2['habbo'], ":time"=&gt;$cur_time, ":ip"=&gt;$ip));
                            echo "Thank you for liking the DJ!";
                        }
                    }
                  ?&gt;
                &lt;/div&gt;
                &lt;div class="radimageoverdiv"&gt;&lt;i class="fa fa-rocket galaxyl" aria-hidden="true"&gt;&lt;/i&gt;&lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/section&gt;
          &lt;nav class="navbar navbar-default"&gt;
            &lt;div class="navbar-header"&gt;
              &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"&gt;
                &lt;span class="icon-bar"&gt;&lt;/span&gt;
                &lt;span class="icon-bar"&gt;&lt;/span&gt;
                &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;/button&gt;
            &lt;/div&gt;
            &lt;div class="navbar-collapse collapse"&gt;
              &lt;ul class="nav navbar-nav"&gt;
                &lt;li&gt;&lt;a href="#home" id="home"&gt;&lt;i class="fa fa-home" aria-hidden="true"&gt;&lt;/i&gt; HOME&lt;/a&gt;&lt;/li&gt;
                &lt;li class="dropdown"&gt;
                  &lt;a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;&lt;i class="fa fa-info-circle" aria-hidden="true"&gt;&lt;/i&gt; HABBFINITY &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                    &lt;li&gt;&lt;a href="#about" id="about"&gt;About Us&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#staff" id="staff"&gt;Our Team&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#contactus" id="contactus"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#sitenews" id="sitenews"&gt;Site News&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="https://twitter.com/Habbfinity" target="_blank"&gt;Follow Our Twitter!&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li class="dropdown"&gt;
                  &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;&lt;i class="fa fa-newspaper-o" aria-hidden="true"&gt;&lt;/i&gt; QUEST &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                    &lt;li&gt;&lt;a href="#badges" id="badges"&gt;Badge Guides&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#wired" id="wired"&gt;Wired Guides&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#news" id="news"&gt;News&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li class="dropdown"&gt;
                  &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;&lt;i class="fa fa-gamepad" aria-hidden="true"&gt;&lt;/i&gt; EVENTS &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                    &lt;li&gt;&lt;a href="#events" id="events"&gt;Events Timetable&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#howto" id="howto"&gt;How To Play&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li class="dropdown"&gt;
                  &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;&lt;i class="fa fa-headphones" aria-hidden="true"&gt;&lt;/i&gt; RADIO &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                    &lt;li&gt;&lt;a href="#radio" id="radio"&gt;Radio Timetable&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#requests" id="requests"&gt;Request Line&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li class="dropdown"&gt;
                  &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;&lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt; GOODIES &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                    &lt;li&gt;&lt;a href="" data-toggle="modal" data-target="#HabboImager"&gt;Habbo Imager&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li&gt;&lt;a href="https://www.habbfinity.ca/forum/" target="_blank"&gt;&lt;i class="fa fa-comments" aria-hidden="true"&gt;&lt;/i&gt; FORUM&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/div&gt;
          &lt;/nav&gt;
        &lt;/header&gt;
        &lt;div id="contfill"&gt;
        &lt;/div&gt;
        &lt;a id="back-to-top" href="#" class="btn btn-primary btn-lg back-to-top" role="button" title="Click to return on the top page" data-toggle="tooltip" data-placement="left"&gt;&lt;span class="glyphicon glyphicon-chevron-up"&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="modal fade" tabindex="-1" role="dialog" id="HabboImager"&gt;
        &lt;div class="modal-dialog modal-lg" role="document"&gt;
          &lt;div class="modal-content"&gt;
            &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
              &lt;h4 class="modal-title"&gt;Habbo Imager&lt;/h4&gt;
            &lt;/div&gt;
            &lt;div class="modal-body"&gt;
              &lt;?php include 'imager.php'; ?&gt;
            &lt;/div&gt;
            &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;script src="assets/js/jquery-3.3.1.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/respond.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/ie10-viewport-bug-workaround.js"&gt;&lt;/script&gt;
      &lt;script src="imagerscript.js"&gt;&lt;/script&gt;
      &lt;script language="javascript" type="text/javascript" src="https://procyon.shoutca.st/system/streaminfo.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        window.SetVolume = function(val) {
            var player = document.getElementById('player');
            player.volume = val / 100;
        }
        function homePageInit() {
            $('[data-toggle="tooltip"]').tooltip();
            $(window).scroll(function() {
                if ($(this).scrollTop() &gt; 50) {
                    $('#back-to-top').fadeIn();
                } else {
                    $('#back-to-top').fadeOut();
                }
            });
            $('#back-to-top').click(function() {
                $('#back-to-top').tooltip('hide');
                $('body,html').animate({
                    scrollTop: 0
                }, 800);
                return false;
            });
            $('#back-to-top').tooltip('show');
            var badgeUrl = 'http://habboo-a.akamaihd.net/c_images/album1584/';
            $.getJSON( 'http://habboemotion.com/api/badge', function( badges ) {
                $.each( badges.list, function( key, badge ) {
                    $('div#badges').append('&lt;img src="'+badgeUrl+badge.code+'.gif" class="thumbnail aleft" alt="Badge" data-toggle="tooltip" data-placement="top" title="'+badge.name+' - '+badge.desc+'"&gt;');
                    return (key !== 11);
                });
            });
            $.getScript('https://platform.twitter.com/widgets.js', function() {
  
            });
            $.getScript('http://habbfinity.ca/forum/external.php?type=js', function() {
                var str = "";
                for (x = 0; x &lt; 4; x++) {
                    str += "&lt;a href=\"http://habbfinity.ca/forum/showthread.php?t="+threads[x].threadid+"\" target=\"_blank\"&gt;"+threads[x].title+"&lt;/a&gt; &lt;br&gt;(Posted By: "+threads[x].poster+")&lt;br&gt;&lt;br /&gt;";
                }
                $("#habbfinity_forum").html(str);
                console.log(str);
            });
        }
        $(document).ready(function() {
          $.ajax({
              url: '&lt;?php echo $page; ?&gt;.php',
              success: function(content) {
                  $("#contfill").html(content);
                  history.pushState(null, '', '&lt;?php echo $page; ?&gt;');
                  homePageInit();
              }
          });
          $('#home').on("click", function(event) {
              $.ajax({
                  url: 'home.php',
                  success: function(content) {
                      $("#contfill").html(content);
                      history.pushState(null, '', 'home');
                      homePageInit();
                  }
              });
              event.preventDefault();
          });
          $('#about').on("click", function(event) {
              $.ajax({
                  url: 'about.php',
                  success: function(content) {
                      $("#contfill").html(content);
                      history.pushState(null, '', 'about');
                      homePageInit();
                  }
              });
              event.preventDefault();
          });
          $('#badges').on("click", function(event) {
              $.ajax({
                  url: 'badges.php',
                  success: function(content) {
                      $("#contfill").html(content);
                      history.pushState(null, '', 'badges');
                      homePageInit();
                  }
              });
              event.preventDefault();
          });
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>