onlycode.org

javascript
jquery
html
css
angularjs
node.js
ajax
html5
php
json
arrays
google-chrome
dom
regex
reactjs
ecmascript-6
javascript-events

your's history:
on window location hash...

On - window.location.hash - Change, just only code?

hashchange | fragment-identifier | javascript-events | ajax | javascript

edit
$(window).on('hashchange', function() {
  //.. work ..
});

36
meandmycode, 01.01.1970 03:00




edit
    if (("onhashchange" in window) && !($.browser.msie)) {
         window.onhashchange = function () {
              alert(window.location.hash);
         }
         // Or $(window).bind( 'hashchange',function(e) {
         //       alert(window.location.hash);
         //   });
    }
    else {
        var prevHash = window.location.hash;
        window.setInterval(function () {
           if (window.location.hash != prevHash) {
              prevHash = window.location.hash;
              alert(window.location.hash);
           }
        }, 100);
    }

34
bonsaiviking, 28.06.2011 18:42



edit
window.location.watch(
    'hash',
    function(id,oldVal,newVal){
        console.log("the window's hash value has changed from "+oldval+" to "+newVal);
    }
);
var myHashLink = "home";
window.location = window.location + "#" + myHashLink;

25
gion_13, 29.10.2010 12:04




edit
window.addEventListener('hashchange', doSomethingWithChangeFunction());
doSomethingWithChangeFunction () { 
    // Get new hash value
    let urlParam = window.location.hash;
    // Do something with new hash value
};

23
Sprose, 07.12.2017 16:36




edit
var page_url = 'http://www.yoursite.com/'; // full path leading up to hash;
var current_url_w_hash = page_url + window.location.hash; // now you might have something like: http://www.yoursite.com/#123

function TrackHash() {
    if (document.location != page_url + current_url_w_hash) {
        window.location = document.location;
    }
    return false;
}
var RunTabs = setInterval(TrackHash, 200);

11
Brett Zamir, 25.02.2011 04:40

Add your just only code

your name:    



If you need full text click here

Some similar links On - window.location.hash - Change? ↓:
of window.location.hash

window location href without hash?

How can I update window.location.hash without jumping the document?

How to remove the hash from window.location (URL) with JavaScript without page refresh?



This project is created for those who just need only code, wihout maaaaaaaaaaany words.