1

Please help me on this how can i use hash function to go to another tab or id without location.reload();.

it should be needed to go to the download tab or id without needing to refresh the page.

here is my code

<script>
function Download() {
   window.location.hash = "#Download";
   location.reload();
}
</script>
SJay
  • 47
  • 5

2 Answers2

0

Do you actually need to use JavaScript for this? What about just using #href attributes to go to another <a> link on the page?

Something like this:

<a id='first' href='#second'>Go to Second Link.</a>
<a id='second' href='#first'>Return to First Link.</a>

See this fiddle for example: https://jsfiddle.net/3axqpr1x/1/

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
jmknoll
  • 1,046
  • 5
  • 11
  • 30
-1

you can try this one;

<script>
function Download() {
   window.location.hash = "#Download";
   location.reload();
}
</script>

Please refer this page Javascript reload the page with hash value

Community
  • 1
  • 1
Ivin Raj
  • 3,448
  • 2
  • 28
  • 65
  • I am not finding any difference between the snippet in question and snippet you provided except there is missing semicolon in this line window.location.hash = "#Download" – brk Feb 05 '16 at 07:02
  • its the same with my code my meaning of this is i need to go to #Download without refreshing the page. – SJay Feb 05 '16 at 07:43
  • You can post a comment like "nothing wrong with your code", no need in a pointless and useless answer just repeating the same code. It's just noise. – Shadow The GPT Wizard Feb 14 '16 at 08:14