Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:25:53+00:00 2026-05-26T18:25:53+00:00

I want to create a site which in the menu will contain links, probably

  • 0

I want to create a site which in the menu will contain links, probably <a> which will send some real hrefs, like /contact/ /services/ etc, so that when google bot visits the site, it will index it as real subpages.

But when the user clicks those links in browser, I don’t want the browser to refresh and reload content, I want the jQuery to shoot and change the content in the proper div, but should probably also change the url somehow, so that user can copy this link to his friends too.

I can do the jQuery content change part, I just don’t know how to create those links so that they don’t refresh the browser when javascript is active, but work properly when javascript is off (google bot).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:25:54+00:00Added an answer on May 26, 2026 at 6:25 pm

    Read about manipulating history

    history.pushState({foo: "bar"}, "page 2", "newpage.html");
    

    First two arguments are not necessary (at least I haven’t seen any useful usage), and I use it exactly like stated below

    <a href="/contact" class="ajax">Contact</a>
    

    with javascript

    $("body").delegate('.ajax', 'click', function(){
        $("#content").html('Loading new content...');
        history.pushState({foo: "bar"}, "dummy", $(this).attr('href'));
        $("#content").load($(this).attr('href')+'?ajax=1');
        return false;
    });
    

    However, the native browser’s back button is not supported. It means that when you hit back button, address changes to the old one but content stays the same. To workaround it, try to use following code

    var popped = ('state' in window.history), initialURL = location.href;
    $(window).bind('popstate', function(event) {
        // Ignore inital popstate that some browsers fire on page load  
        var initialPop = !popped && location.href == initialURL
        popped = true
        if ( initialPop ) return;
        $("#content").load(location.href+' #content');
        return false;
    });
    

    which will load old content as soon as user hits back button.

    Also, you have to note that .pushState doesn’t work on outdated browsers and therefore you should create a fallback for users without this feature.

    Eventually, as of jQuery 1.7, use .on() instead of .delegate(), because it’s faster and is being replaced. So instead of delegating whole body, we can use

    $(".ajax").on('click', function(){
        $("#content").html('Loading new content...');
        history.pushState({foo: "bar"}, "dummy", $(this).attr('href'));
        $("#content").load($(this).attr('href')+'?ajax=1');
        return false;
    });
    

    which will attach event handler just to the specific elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create some command line utilities to manage many wordpress site, allowing
I want to create a simple CMS for my asp.net-mvc site. Will I save
NET MVC and i want to create a class to contain site wide functions
Hi I want to create a vehicle insurance broker site which gets insurance prices
I want to create a classifieds site in which the ads posted by users
I want to create an app which gets data from a blog site and
I want to create a webPage using HTML 5 which will use all the
I'm tasked with trying creating a site which will create custom HTML templates. The
i want create something like link_to which can link to request for permission in
I want to create site thumbnails through my web application, so I thought I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.