Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

536
Views
Javascript - Forward Slash appended automatically in URL with the Window.Location.Hash

In my Angular JS website, I wish to append the text "#Page/" to the URL using Javascript. Here my problem is that the forward slash(/) is getting added when using the code Location.hash

For example, Let say the URL is https://MyWebsite.com/Products

        var location = window.location;
        location.hash = "#page/" + pageNumber;
        window.location = location
       
    

After executing the above code, the Window.location turned out to be https://MyWebsite.com/Products/#page/1.

But what I need is the forward slash(/) should not be included between products and #page. https://MyWebsite.com/Products#page/1.

The strange thing is that when I checked the same code with the other websites don't have Angular JS, implemented only with the Asp.net Webforms and ASP.net MVC, I got the desired result.

Does this kind of issue have something to do with the Angular JS?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe # is special character reserved for a page fragment reference. See https://www.ietf.org/rfc/rfc3986.txt

Can you do with without # or use the # to reference the fragment? e.g.

window.location.href += 'page/' + pageNumber + '#' + pageFragment;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!