javascript - How to store user input urls (anchor links) and redirect user using window.location? -


i managed create condition detect anchor link, after how store anchor link in anchor_num variable, can redirect use specific url?

<script type="text/javascript">  $(function(){      if(window.location.hash){          var anchor_num = "anchorstring";         window.location = "#"+ anchor_num;      } else            {             //redirect default page           } });  </script> 

by appending or changing hash browser wouldn't refresh page. should call window.location.reload() after you've set hash:

window.location = "#"+ anchor_num; window.location.reload() 

Comments

Popular posts from this blog

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -