Interfaz de página única y JQuery

i built a site which can be accessed through a normal index.php. So the URL is Now i want to add links at the bottom which look like this, which should then include an aboutme.php into a div in the index.php. I googelt a little bit and found various solutions via javaScript, which look like this:

var url = window.location.href;

Then i should parse the url and if "aboutme" is mentioned, include the .php file into the specific div with JQuery.

Is that the best solution available? I'm a bit puzzled right now...


Edit: I'm not looking for a solution to include content via JQuery into a div. I know how to do it. The question is more, how to parse the URL. Because if the user types in the aboutme.php should be included in the div. So, i have to detect this at the top of my page. My question is: Is it the most feasible solution to catch the url with the command above and parse it e.g with a switch-statement?

preguntado el 09 de marzo de 12 a las 15:03

3 Respuestas

To load information into one div from a click action you can start with this:

$('a').click(function(e) {
    var thisHREF = $(this).attr('href');
    $('#content').load(thisHREF); // div id="content" is in index page

respondido 09 mar '12, 15:03

$("#your_link").click(function() {
   return false;

respondido 09 mar '12, 15:03

you can use jQuery load to load content about differnet parts of your page

Use a div which will act as a place holder to show content of different pages. and when user clicks on differnet links, load the content to the div. Your main url remains the same. But if you want , you can append some string ( ex : about) to the url as well


<div id="divPageContent"> </div>

<div class="divFooterLinks">
     <a href="about.php">About</a>
     <a href="contact.php">About</a>



   $(".divFooterLinks a").click(function(){     
     return false;


from about.php, Just return the Markup for central content. because your main page already have header and footer etc...

respondido 09 mar '12, 15:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.