It definitely does, because I noticed when using IE that first it goes to the specified anchor, and then drops down to the new-comment box (if it's supposed to go to the last comment, well, that doesn't work quite right either).
That is the javascript that opens the comments, but it hasn't been adequately escaped, or something, so it comes up all invisible!!! oh noes!!
function OpenComments (c) {
window.open(c,
'comments',
'width=480,height=480,scrollbars=yes,resizable=yes,status=yes');
}
Note that there's nothing here that screams "I want to go to the bottom of the page!"
In IE the "read more" link doesn't actually get you anything.
That's because I can't friggin' remember how to quote code.
I am so smrt. Here's what does it. It's in the code in each of the comments pages:
function doOnload(){
document.getElementById("email").value = getCookie("mtcmtmail");
document.getElementById("author").value = getCookie("mtcmtauth");
document.getElementById("url").value = getCookie("mtcmthome"); document.getElementById("author").focus();
document.getElementById("author").select();
}
That's responsible for filling in the saved data for commenters what have selected to have their data saved. But the last line causes the "author" field to be active, so the cursor goes there—which drags ineluctably the scrollbar and with the scrollbar the window. Comment out that line and I'll bet your problems are solved.
That'll be $150.
Thanks Ben! It was the "author / focus" line that was the problem. Now, tell me again, how do I quote code so that it shows up on the page??
I wasn't doing anything special at all. The only things you have to watch out for are > and <, and ampersands. Those have to be escaped.
When you say "escaped," that means what, exactly?
Well, ogged, I'm glad you asked! I'm pretty sure I've addressed this already in some comment thread here or other, but no matter. As I'm sure you know, since you wrote the HTML for this site by hand, the less-than and greater-than signs signal the start and end of tags. That means that if you're going to display them on your page, you can't just write them, bare, and expect them to show up, because the parser will barf (I believe that's the technical term). So, you have to write them some other way. That way is to write "<" for less than ("gt" for greater than).
You don't actually need to escape ampersands in all cases, but if you want to write something like the above, you do. Had I written, in this text area, "<", what would have shown up would be <, since the ampersand would have been interpreted as the start of an escape sequence. Consequently, I had to escape it: & (which, to me as I write, looks like this: &amp;).
Thanks again. Yes, you'd addressed it before, but I couldn't find it.
Ah...here it is (and that's a working link, bud).
This is a neat article that involves escaping.
But... but... I LIKED being taken to the bottom of the comments.
Just testing out this phat knowledge.
>boo yeah<
What I want is a program that sets a cookie so it takes you not to the bottom, but to the last comment you yourself actually viewed.
I liked being taken to the bottom too (bada-bing?), but I like being able to link to comments even more. If someone knows a way to do both, I'll do it.
I bet if you modified the function doOnload to contain, at the end, these lines it would work:
if (!document.href.contains("#")) {
document.getElementById("author").focus();
document.getElementById("author").select();
}
I suspect that then you would be able to link to a single comment (since named anchors include the # character), but if you just open the comments link at the bottom of each post, it will go to the bottom.
The whole function would then be:
function doOnload(){
document.getElementById("email").value = getCookie("mtcmtmail");
document.getElementById("author").value = getCookie("mtcmtauth");
document.getElementById("url").value = getCookie("mtcmthome");
if (!document.href.contains("#")) {
document.getElementById("author").focus();
document.getElementById("author").select();
}
}
whoops! Change that conditional to be "if(document.href.indexOf("#") == -1)".
Man. And I can barely capitalize a sentence.
I posted this in the thread above, but no one seems to have noticed:
How about just a button or link at the top of the comments box that executes the same line of Javascript you just commented out of the OnLoad function (i.e. going to the bottom of the page)? That way, those who like it can use it, and those who don't, can... not use it.
Walter - you could always just hit the 'End' button on your keyboard.
Baby, you can hit the 'end' button on my keyboard whenever you want to.
W-A-W, wouldn't it be great if that button were real?
Not that I'd need it. But for some people.
Ben, doesn't seem to have worked; doesn't go to the bottom. Here's what I have:
function doOnload(){
document.getElementById("email").value = getCookie("mtcmtmail");
document.getElementById("author").value = getCookie("mtcmtauth");
document.getElementById("url").value = getCookie("mtcmthome");
if(document.href.indexOf("#") == -1) {
document.getElementById("author").focus();
document.getElementById("author").select();
}
}
Well, I was trying to offer Ogged a Javascript solution, since that seemed to be what he was looking for. Anyway, there are always 18 million different ways to do the same thing on a computer, but Javascript buttons have caché.
maybe it's document.location? I don't actually know javascript. I'd try document.location instead of document.href.
That doesn't work either. Doesn't matter, really. Thanks for trying.
Oh, by the way, that line should be "window.location.href" if you still want to try it.
Speaking of recent nerdiliciousness, The Poor Man has finally jettisoned Teh Suck.
Whoa! Sobchak's code worked, I guess.
The Poor Man has finally jettisoned Teh Suck.
Thank god! That old site was killing me.
So I was thinking about another cool feature you might try adding: in the OnLoad function, after it fills in the Name/e-mail/URL from the cookie, you can have it check to make sure those values were found, and if so, select the comment box instead of the name box, so that way it saves people who have already put in their info a little bit of scrolling and a click. And it only requires a few more lines of code. Here's the full re-written function:
function doOnload(){
document.getElementById("email").value = getCookie("mtcmtmail");
document.getElementById("author").value = getCookie("mtcmtauth");
document.getElementById("url").value = getCookie("mtcmthome");
if(window.location.href.indexOf("#") == -1) {
if(document.getElementById("author").value == "") {
document.getElementById("author").focus()
document.getElementById("author").select()
}
else { document.getElementById("comment").focus()
}
}
}
Cool, or just anal retentive?
No, that is cool, Walter. I'll try it out.