0
<?php $view = $_REQUEST["view"];
$default_header="index-home.php";

switch ($view) {

    case "voorwaarden":
      include("index-voorwaarden.php");
      break;

    default:
      include($default_header);
}
?>

Is there anyway to do this with javascript or jquery and ajax, so that the link won't change but goes to a different page like test.com and show home and when you click a link it stays on test.com but with completely different content

Thanks, Sake

  • you need to explain more we didnt get what u actully want to archive ? – Anant Dabhi Apr 07 '14 at 13:22
  • What I want to do is that you go to a different page with different stylesheets etc. without changing the link. So if you click a link on the page, you will stay at the same link (test.com) but actually go to a different page –  Apr 07 '14 at 13:24
  • if u want to show diffrent page in diffrent url request you should go with url rewriting http://stackoverflow.com/questions/16388959/url-rewriting-with-php – Anant Dabhi Apr 07 '14 at 13:26
  • you can visit here... http://css-tricks.com/snippets/javascript/get-url-variables/ – Muhammad Irfan Apr 07 '14 at 13:33

2 Answers2

0

You can output it to a javascript variable and have it pick up from there:

<?php
  $view = $_REQUEST['view'];
?>
<!-- ... -->
<script>
  var view = '<?= $view ?>';
  switch (view){
    case '...':
      break;
    case '...':
      break;
  }
</script>
<!-- ... -->

But now you'd need either AJAX or an iframe to include the content(s).

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
0

here is the function to get or you can visit this question How can I get query string values in JavaScript?

function getQueryVariable(variable)
{
   var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i=0;i<vars.length;i++) {
           var pair = vars[i].split("=");
           if(pair[0] == variable){return pair[1];}
   }
   return(false);
}
Community
  • 1
  • 1
Muhammad Irfan
  • 228
  • 1
  • 8