OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can I replace a window's URL hash with another response?

  • Thread starter Thread starter Barlas Apaydin
  • Start date Start date
B

Barlas Apaydin

Guest
I am trying to change a hashed URL (document.location.hash) with the replace method, but it doesn't work.

Code:
$(function(){
 var anchor = document.location.hash;
 //this returns me a string value like '#categories'

  $('span').click(function(){

     $(window).attr('url').replace(anchor,'#food');
     //try to change current url.hash '#categories'
     //with another string, I stucked here.
  });

});

I dont want to change/refresh page, I just want to replace URL without any responses.

Note: I don't want to solve this with a href="#food" solution.

<p>I am trying to change a hashed URL (document.location.hash) with the replace method, but it doesn't work.</p>

<pre><code>$(function(){
var anchor = document.location.hash;
//this returns me a string value like '#categories'

$('span').click(function(){

$(window).attr('url').replace(anchor,'#food');
//try to change current url.hash '#categories'
//with another string, I stucked here.
});

});
</code></pre>

<p>I dont want to change/refresh page, I just want to replace URL without any responses.</p>

<p>Note: I don't want to solve this with a href="#food" solution.</p>
 

Latest posts

Top