So I wish to work with #hash links..
As I cannot manipulate the history links, if HTML5 isnt supported I wish to add #photoid=12345 to the link (example).
Now how can i check in PHP if there is any in #photoid ? I cant do normally
if(isset($_GET["photoid"])))
so what should i do开发者_如何学Python here to detect where anything is in #photoid?
You can't. The fragment identifier is handled purely on the client and is never sent to the server so PHP can't read it.
You'll need JavaScript for that:
var hash = window.location.hash;
alert(hash);
Edit: you can then call on a php script and use this information. Example in jQuery:
$.post('do_something.php', {
// send the parameter 'hash'
hash: hash
}, function(result) {
// do something with the result
// e.g. add it to a div with an id "photos":
$('#photos').html(result);
});
And "do_something.php" could look like this:
$hash = $_POST['hash'];
// do something, e.g. retrieve a photo based on the posted hash and echo it
// this will be in the result variable that's retrieved via Javascript
echo '<img src="photo_from_hash.jpg" alt="" />';
精彩评论