From the link in your post:
The hash is never sent to the server, so no.
In fact, even though it is always sent to the browser, it doesn't always trigger an onload event for the page. For instance, if you have a link on your page:
HTML Code:
<a href="#huh">Huh</a>
If you click it and you have a script on the page (I know you're using jQuery):
Code:
jQuery(function($){
alert(location.hash);
});
which will execute on DOM load. It will do nothing because the DOM is already loaded and clicking on the example link doesn't cause another DOM load.
FYI - the DOM load executes as part of every onload event, simply a little sooner.
Now, you can do something like this:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
$('#sender').click(function(){
var hash = this.hash.substring(1);
if(hash){
$.ajax({url: 'data.php', data: {'anchor' : hash}, type: 'POST', cache: false, success: function(d){
$('#result').html(d);
}
});
}
});
});
</script>
</head>
<body>
<div id="result">Result will go here</div>
<a id="sender" href="#huh">Huh</a>
</body>
</html>
data.php:
Code:
<?php
$anchor = isset($_POST['anchor'])? $_POST['anchor'] : '';
echo $anchor;
?>
and it will work because it's set on the link's click event and therefore doesn't rely upon a page load to detect a change in the hash.
Bookmarks