Re: Geek Help Needed

1

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).

horizontal rule
2

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!"

horizontal rule
3

In IE the "read more" link doesn't actually get you anything.

horizontal rule
4

That's because I can't friggin' remember how to quote code.

horizontal rule
5

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.

horizontal rule
6

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??

horizontal rule
7

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.

horizontal rule
8

When you say "escaped," that means what, exactly?

horizontal rule
9

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 "&lt;" 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, "&lt;", 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: &amp; (which, to me as I write, looks like this: &amp;amp;).

horizontal rule
10

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).

horizontal rule
11

This is a neat article that involves escaping.

horizontal rule
12

But... but... I LIKED being taken to the bottom of the comments.

horizontal rule
13

Just testing out this phat knowledge.

>boo yeah<

horizontal rule
14

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.

horizontal rule
15

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.

horizontal rule
16

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();

}

}

horizontal rule
17

whoops! Change that conditional to be "if(document.href.indexOf("#") == -1)".

horizontal rule
18

Man. And I can barely capitalize a sentence.

horizontal rule
19

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.

horizontal rule
20

Walter - you could always just hit the 'End' button on your keyboard.

horizontal rule
21

Baby, you can hit the 'end' button on my keyboard whenever you want to.

horizontal rule
22

*punches Matt in the kidneys*

horizontal rule
23

W-A-W, wouldn't it be great if that button were real?

Not that I'd need it. But for some people.

horizontal rule
24

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();

}

}

horizontal rule
25

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é.

horizontal rule
26

maybe it's document.location? I don't actually know javascript. I'd try document.location instead of document.href.

horizontal rule
27

That doesn't work either. Doesn't matter, really. Thanks for trying.

horizontal rule
28

Oh, by the way, that line should be "window.location.href" if you still want to try it.

horizontal rule
29

Speaking of recent nerdiliciousness, The Poor Man has finally jettisoned Teh Suck.

horizontal rule
30

Whoa! Sobchak's code worked, I guess.

horizontal rule
31

Thanks, Walter!

horizontal rule
32

The Poor Man has finally jettisoned Teh Suck.

Thank god! That old site was killing me.

horizontal rule
33

Day nadda, ameego.

horizontal rule
34

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?

horizontal rule
35

No, that is cool, Walter. I'll try it out.

horizontal rule