Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 155 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

/questions/1509416/how-to-get-the-latest-record-among-3-different-table-in-mysql/1509429#1509429

I didn't see an element with id 1509429 but it still works,how?

share|improve this question

That is referring to an answer rather than a question. The first number in the URL is the question number. The name of the question can change if someone with authority (permission) edits the title, so I suspect that the value in the permalink is immaterial.

Indeed, some playing with permalinks shows that the text portion is effectively ignored; you can reduce it to a single character, or remove all the characters, or remove the slash too. Thus, all these get to this answer:

The first of the two numbers separated by the '#' (hash) symbol is the answer number - as part of the URL, it instructs Stack Overflow to load the page with that answer on it (only really meaningful for questions with multiple pages of answers, but a link wouldn't be very *perm*anent if it broke once too many answers were posted).

The number after the hash (the URL "fragment") is also the answer number - but this time it instructs the browser to scroll that answer into view once the page has loaded.

Oh, and you're right - there's no element with an id set to the answer number; it's an honest-to-goodness anchor!

<a name="1509429"></a>

(Thanks to @shog9 for some previous additional information - the last couple of paragraphs, roughly.)

share|improve this answer
    
Can you explain what <a name="1509429"></a> exactly means?I've never seen the name attribute to work in the DOM other than posting values. – Shore Oct 4 '09 at 8:06
    
@unknown: see w3.org/TR/REC-html40/struct/links.html#h-12.2.1 – Shog9 Oct 4 '09 at 8:10
    
Oh,I've never known about this before! – Shore Oct 4 '09 at 8:20
    
But this still doesn't explain why 1509429#1509429 is neccesary,which is my third comment to Jeff Atwood. – Shore Oct 4 '09 at 9:55
1  
@Shore - Actually it does - Step 1) The request returns the question with the page selected for that answer (specified by /1509429 - this doesn't happen if you leave this portion of the URL out), Step 2) The browser loads the page, and moves to the anchor specified by #1509429 - no need for any JavaScript to perform this action (which would be required if you left off the hash portion of the URL) – gnarf Oct 4 '09 at 11:33
1  
@shog9 - thanks for the assist. I suspect you should be getting more of the credit than me. :D – Jonathan Leffler Oct 4 '09 at 19:47

hint: one of these things can be seen by the server and the client browser, while the other can only be seen by the client browser.

share|improve this answer
    
I think you used url rewrite,can you tell me what's the url after rewriting? – Shore Oct 4 '09 at 8:11
    
Is it something like /questions?id=1#3212? – Shore Oct 4 '09 at 8:18
1  
But I don't see the reason to twice the number like /1509429#1509429,isn't /1509429 enough? – Shore Oct 4 '09 at 8:19
3  
#1509429 directs browsers (even with JavaScript disabled) to scroll down to the named anchor point in the document. – gnarf Oct 4 '09 at 11:34
1  
What gnarf said, with the addition that this information is not passed to the server, and so it is necessary to include that tag a second time so the server knows which answer you're talking about. – Joel Coehoorn Oct 4 '09 at 20:05
    
@ Joel Coehoorn,if I can check a comment as the answer,I'll do it on you! – Shore Oct 6 '09 at 17:50

The old way for bookmarks to work was with a named hyperlink, and this is the method that SOFU uses, for example:

<a name="24523"></a>
share|improve this answer

Named anchors (<a> tags) are a way to link to specific parts of a page..

Say you have a long page, and in the middle, the following HTML:

<a name="1509429"></a>

When you navigate to http://example.com/mypage.htm#1509429 the browser will jump to where the above HTML is.

Simply put, the #1509429 makes the browser scroll the appropriate answer, rather than the top of the page (as a normal link would)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .