Hi...

I have a simple function for loading php pages into the index.php file. I'm wanting to incorporate pushstate() so I can start making the page crawlable. But not sure how.

Here's my starting point (which just gives me "http://www.site.com/undefined"

// function for navigation clicks

    $("#top_nav li a, #footer_info").on("click", function(e){

                // prevent the a href from doing what it naturally does.
                e.preventDefault();

                // highlight active nav link & turn off others              
                $('.current').attr('class','link1');



                // which page chosen?
                var loadpage = 'inc/'+$(this).attr('name')+'.php';
                var footer = 'inc/footer.php';



                    $('#main_center_box,#footer_links').stop().animate({ opacity: 0, zIndex:0 }, 700, function() { 
                        $(this).attr('class','current');

                        // now load the page that matches navigation selected
                        $('#main_center_box').css({zIndex:1 }).load(loadpage).stop().animate({ opacity: 1}, 700, function() { /* animation complete */ });
                        $('html,body').scrollTop(0);

                        // not sure how to do this part...
                        href = $(this).attr(loadpage);
                        history.pushState('', 'New URL: '+href, href);
                    });

    });

good lord...

It helps if I have a url in the href.

Ok. that's solved. Now how to make things crawlable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.