I have somes links like this:
mywebsite.com/tutos.php?name=tuto_name#comments
mywebsite.com/tutos.php?name=tuto_name#download
My question: how to get the text after the #.
thanks.
I have somes links like this:
mywebsite.com/tutos.php?name=tuto_name#comments
mywebsite.com/tutos.php?name=tuto_name#download
My question: how to get the text after the #.
thanks.
 
    
     
    
    window.location.hash is a cross browser solution that returns the value (including the hash)
You can remove the hash by doing:
var hash = window.location.hash.substr(1);
 
    
    You can use window.location.hash. It takes with # (ie, #comments). To remove trialing # use .substring(1). Example:
var str = window.location.hash.substring(1);
alert(str);
 
    
    I use the following JS function that will do this:
function getURLParameter(name) {
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)','i').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
}
 
    
    I use the following as it not only grabs the hash value (without the hash itself (taking the 2nd part (array[1] of the split)), but also tests the undefined case as well which can cause problems in some cases.
var hashVal = window.location.hash.split("#")[1];
if( hashVal && hashVal != "undefined" ) {
       //work it 
 }
