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 8363321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:09:00+00:00 2026-06-09T12:09:00+00:00

So long story short im working on a web app and using AJAX within

  • 0

So long story short im working on a web app and using AJAX within it.
I’m trying to disable the default actions of links when clicked, attach a hash value to the link and then remove the "#" from the url.

the problem im having is that, although the hash values are being attached accordingly, the substring method isnt extracting the "#", it extracts the letter after it…..

here is my code. PS, i left my comments inthere so you get where im trying to go with this
so i dont know….my logic or setup may be wrong….

$(document).ready(function(){
    
    //app vars
    var mainHash = "index";
    var menuBtn = $('.leftButton');
    //~~~~~~load the index page at first go.
    loadPage();
    
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~menu show/hide
    menuBtn.click( function(){
        $('#menu').toggleClass();   
    });
    
    
    //Menu items on click , disable link default actions.
    $('#menu a').click( hijackLinks );
    
    
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~functions for mobile index load AND hijacking app links to AJAX links.
    function loadPage(url){
        if( url == undefined){
            $('#contentHere').load('index.html #content', hijackLinks);
                window.location.hash = mainHash;
        } else {
            $('#contentHere').load(url + '#content', hijackLinks ); 
        }
    }
    
    
    function hijackLinks(e){
        var url = e.target.href;
        e.preventDefault();
        loadPage(e.target.href);
        window.location.hash = $(this).attr("href").substring(1);
    }
});

what im wanting is to remove the "#" from the url. What am i doing wrong, what am i not seeing/understanding?

ive tried substring/substr etc and both do the same thing in that no matter what numbers i choose to insert into the substrings params, they remove EVERYTHING BUT the "#" lol….

  • 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-06-09T12:09:01+00:00Added an answer on June 9, 2026 at 12:09 pm

    Well, you don’t really change the link itself, you only change the window.location.hash, and the hash always has a “#” at the beginning.

    What you need to do in order to change the entire url (and remove the ‘#’) is to manipulate the browser history.

    Although you should know it works only in newer browsers (the exact browser versions are in the link), so if you target your website to older too browsers you might need to think about having a fallback using the hash. If you decide to have such a fallback, I suggest searching for a plugin which does it instead of making it all yourself.

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

Sidebar

Related Questions

So to make a long story short, I've been working on a web app
So long story short, im working with some jquery tabs and im using this
To cut a long story short, my project (an iPhone app) was all working
I'm working with jQuery Mobile, trying to unbind hover from links – long story
This is a weird one. Long story short: wrote a usercontrol using AJAX. Used
I am trying to teach myself AI using neural networks. Long story short, I
Long story short, I have an ASP.NET application I'm trying to debug and at
Long story short, the database I'm using needs to get looked at. Until that
Long story short, client's hosting is using php 5.2.5 and i desperately need to
Long story short, I'm working on a .NET profiler that at one point gets

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.