Coding Help

Users should come to the Embassy to make all suggestions, bug reports, complaints, and anything else relating to the forum itself. The Embassy Control staff will take all issues seriously. Or kill you. One of the two. Possibly both.
Post Reply
User avatar
3278
No-Life Loser
Posts: 10224
Joined: Thu Feb 14, 2002 8:51 pm

Coding Help

Post by 3278 »

Does anyone happen to know what the optimal way of moving the caret to a given dialog box is? I'd like to arrange it so that when people aren't logged in, and they view a page, the cursor is automatically already in the Username field, and I know there are a variety of ways to do this: what's the best?

I'm considering setting it up so that if you're logged in and view the Posting page, it'll automatically be in the Subject or Message body fields, too, but first thing's first.
User avatar
DV8
Evil Incarnate
Posts: 5986
Joined: Mon Mar 18, 2002 6:49 am
Location: .nl
Contact:

Post by DV8 »

The focus() method of the object?
User avatar
DV8
Evil Incarnate
Posts: 5986
Joined: Mon Mar 18, 2002 6:49 am
Location: .nl
Contact:

Post by DV8 »

Specifically; you insert a javascript snippet right underneath the html of the input tag so in which you do a document.getElementById("username").focus();
User avatar
3278
No-Life Loser
Posts: 10224
Joined: Thu Feb 14, 2002 8:51 pm

Post by 3278 »

I couldn't get getElementById to work, for whatever reason - placement? - so I named the form "credentials," and then used:

Code: Select all

          <script language="Javascript">
            <!--
              document.credentials.username.focus&#40;&#41;;
            //-->
          </script>
Seems to work fine, but is this contraindicated for any reason? Is there any excess code I can take out?
User avatar
DV8
Evil Incarnate
Posts: 5986
Joined: Mon Mar 18, 2002 6:49 am
Location: .nl
Contact:

Post by DV8 »

The getElementById probably didn't work because the input element didn't have an id. What you came up with will also work; I don't know of any reason not to use it.
User avatar
3278
No-Life Loser
Posts: 10224
Joined: Thu Feb 14, 2002 8:51 pm

Post by 3278 »

Seems like phpBB's element naming is pretty inconsistent: I noticed several cases while I was in there of elements without IDs or names, and some with. Understandable, but I don't like inconsistent.
User avatar
3278
No-Life Loser
Posts: 10224
Joined: Thu Feb 14, 2002 8:51 pm

Post by 3278 »

Our new fixed headers and footers are neat, to be sure, but they're terribly hacked together. The code is ridiculously untidy, and there are inconsistencies [again] across templates [which are on the list to be fixed]. But my biggest problem is a kludge I'm not very proud of. It's a very 1998 solution to a 2008 problem.

Here's the thing: then you give your header a fixed position, the rest of the page ignores its existence. If your header runs from 0 to 100 pixels, and you fix its position, the body of the page won't start rendering at 101 pixels, it'll start rendering at 0 pixels, and be obscured by the fixed elements. This was actually a problem for a long time over at the d20 SRD, but he's somehow fixed it. I looked over his CSS, and I don't see the solution; I was able to make the header vanish, but I didn't think that was very helpful.

Now, in theory, I could solve the problem by making the body of the page relatively positioned, and pushing it all down by a fixed quantity. The problem here is that I'd have to do it to dozens of pages, or else put the whole body in a table or div that opens in the header and closes in the footer, but when you do that, scrolling the page makes the body scroll so that it's not obscured by the header [so that it's "above" the header, in terms of layers; between the header and the user], and so that user interactions take place on the body layer and not the header layer as one scrolls past the other.

My solution has been a spacer gif that we use for some of the fine-tuning on that image cluster in the upper-left [which wasn't as easy as it looks to make work properly in all browsers]. It's 160 pixels tall, and sits in the header /file,/ but not in the fixed header /table./ It's inelegant, but it works; still, I'd prefer another solution. Anyone?
User avatar
3278
No-Life Loser
Posts: 10224
Joined: Thu Feb 14, 2002 8:51 pm

Post by 3278 »

Yeah, and there needs to be a fix for this, too, because when following a "most recent post" link, it doesn't respect the spacer, and hides much of the linked post. Unacceptable.
Post Reply