Thursday, June 6, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  55] [ 5]  / answers: 1 / hits: 82818  / 12 Years ago, mon, may 21, 2012, 12:00:00

I learned window.location.hash new and tried in my jquery code instead of window.location.href and both of them gave same results.



Code is here :



window.location.href = ($(e.currentTarget).attr(href));
window.location.hash = ($(e.currentTarget).attr(href));


What is the difference between them?


More From » jquery

 Answers
58

For a URL like http://[www.example.com]:80/search?q=devmo#test



  • hash - returns the part of the URL that follows the # symbol, including the # symbol. You can listen for the hashchange event to get notified of changes to the hash in supporting browsers.


    Returns: #test


  • href - returns the entire URL.


    Returns: http://[www.example.com]:80/search?q=devmo#test





Read More


[#85449] Saturday, May 19, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rickjordond

Total Points: 100
Total Questions: 105
Total Answers: 90

Location: Sweden
Member since Mon, May 8, 2023
1 Year ago
rickjordond questions
;