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


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 10:43 AM
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!"


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 10:56 AM
horizontal rule
3

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


Posted by: Matt Weiner | Link to this comment | 03- 3-05 10:56 AM
horizontal rule
4

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


Posted by: ogged | Link to this comment | 03- 3-05 10:58 AM
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.


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 11:03 AM
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??


Posted by: ogged | Link to this comment | 03- 3-05 11:11 AM
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.


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 11:23 AM
horizontal rule
8

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


Posted by: ogged | Link to this comment | 03- 3-05 11:24 AM
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;).


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 11:30 AM
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).


Posted by: ogged | Link to this comment | 03- 3-05 11:33 AM
horizontal rule
11

This is a neat article that involves escaping.


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 11:37 AM
horizontal rule
12

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


Posted by: girl27 | Link to this comment | 03- 3-05 12:38 PM
horizontal rule
13

Just testing out this phat knowledge.

>boo yeah<


Posted by: Michael | Link to this comment | 03- 3-05 1:19 PM
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.


Posted by: bitchphd | Link to this comment | 03- 3-05 1:40 PM
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.


Posted by: ogged | Link to this comment | 03- 3-05 2:12 PM
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();

}

}


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 2:22 PM
horizontal rule
17

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


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 2:23 PM
horizontal rule
18

Man. And I can barely capitalize a sentence.


Posted by: Joe Drymala | Link to this comment | 03- 3-05 2:24 PM
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.


Posted by: Walter Sobchak | Link to this comment | 03- 3-05 2:25 PM
horizontal rule
20

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


Posted by: apostropher | Link to this comment | 03- 3-05 2:27 PM
horizontal rule
21

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


Posted by: Matt Weiner | Link to this comment | 03- 3-05 2:30 PM
horizontal rule
22

*punches Matt in the kidneys*


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 2:31 PM
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.


Posted by: Joe Drymala | Link to this comment | 03- 3-05 2:31 PM
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();

}

}


Posted by: ogged | Link to this comment | 03- 3-05 2:32 PM
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é.


Posted by: Walter Sobchak | Link to this comment | 03- 3-05 2:33 PM
horizontal rule
26

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


Posted by: ben w-lfs-n | Link to this comment | 03- 3-05 2:34 PM
horizontal rule
27

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


Posted by: ogged | Link to this comment | 03- 3-05 2:37 PM
horizontal rule
28

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


Posted by: Walter Sobchak | Link to this comment | 03- 3-05 2:47 PM
horizontal rule
29

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


Posted by: Joe Drymala | Link to this comment | 03- 3-05 2:49 PM
horizontal rule
30

Whoa! Sobchak's code worked, I guess.


Posted by: Joe Drymala | Link to this comment | 03- 3-05 2:50 PM
horizontal rule
31

Thanks, Walter!


Posted by: ogged | Link to this comment | 03- 3-05 2:51 PM
horizontal rule
32

The Poor Man has finally jettisoned Teh Suck.

Thank god! That old site was killing me.


Posted by: ogged | Link to this comment | 03- 3-05 2:53 PM
horizontal rule
33

Day nadda, ameego.


Posted by: Walter Sobchak | Link to this comment | 03- 3-05 2:56 PM
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?


Posted by: Walter Sobchak | Link to this comment | 03- 4-05 8:23 PM
horizontal rule
35

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


Posted by: ogged | Link to this comment | 03- 4-05 8:27 PM
horizontal rule