Closed Thread Icon

Topic awaiting preservation: Focus Form Element (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8592" title="Pages that link to Topic awaiting preservation: Focus Form Element (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Focus Form Element <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 03-31-2003 17:37

Hello,
I'm trying to focus the first form element, but rather than stick the code at the end of the HTML, I'd rather place the code in javascript, err.... I'd like to add an event to the body onLoad event.
So I have a function which pops up a new window. This new window will have a form on it. It is in this function that I'd like to add the onLoad event for the body element... I'm doing it this way because it just feels better to me.

Here's what isN'T working:
win.document.body.onLoad = FocusForm();

I get the error:
..."body is null or not an object'...

In advance, thanks for the help : )

Karl



karl@laketahoegymnasticscamp.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-31-2003 17:44

Well... I'm not sure why it gives that particular error message, but here are some issues with the code:

1. there's no such thing as "win". Use "window", or just omit it entirely (leaving document.body...).

2. use "onload", not "onLoad". I don't know where the idea that events need to have capital letters inside them came from, but it's not required in HTML, and it doesn't work in JavaScript.

Now, there may be more errors inside FocusForm().

Keep in mind that if you post a link to the problematic page, we could do more than just make guesses at what's wrong like this. 'Cause ten bucks says, despite my efforts in this post, after making the changes something will still be wrong because I didn't have the full story.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 03-31-2003 18:03

Hi there,

Its a bit difficult to post the code, I'm developing on my box here within our intranet.

"win" is an object, it is assigned in the window.open event here:
win=window.open('edit.asp?id=' + id + '&ax=2','edit','width=250,height=175,resizable=no,scrollbars=yes');


I've tried a bunch of different versions of "body.onload=" "win.onload=" "win.document.body.onload="...
The best I can come up with now is the error:
"Not Implemented".

I think my scope is off or something.

Ugggg...
Karl


karl@laketahoegymnasticscamp.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-31-2003 18:21

Oooh, you can't assign anything to the document's body until the document's body has loaded.

Oh, wait, here's the thing: you don't even have to assign onload to the document's body. The fact that in HTML it goes in the body tag is unimportant. You can just assign it to the window object itself:

win.onload = blah

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 03-31-2003 18:36

Ahh... hmm... shall try! Thanks.


karl@laketahoegymnasticscamp.com

« BackwardsOnwards »

Show Forum Drop Down Menu