has no properties

This is a discussion on "has no properties" within the JavaScript Forum section. This forum, and the thread "has no properties are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 5th, 2004, 18:35
New Member
Join Date: Aug 2003
Location: USA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
has no properties

I have a js function

function focus(WhereFocus){WhereFocus.focus}

in a js script block. It's called from body onload event:

<body onLoad="focus(<%=WhereFocus%>);">

this is within a vbscript function which writes the header of each page in an application; I pass this function the name of the page and where I want initial focus for the page to be. Many times it is simply 'document' but sometimes it's to a form element.

It is getting written to html like this:

<BODY onLoad="focus(document.login.ID);">
or
<BODY onLoad="focus(document);">

It works fine in IE and NS7, though in NS7 if I invoke the js console I see the report:

Error: WhereFocus has no properties

In Netscape 4.7, focus is put correctly, but I get this error:

WhereFocus is not a function.

Anyone know what I'm doing wrong?

Thanks -

  #2 (permalink)  
Old Jan 5th, 2004, 21:21
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
A few things...

First off you're always asking for trouble when you use reserved words for function names or variables. So instead of calling your function "focus" which as you know is an object method name I'd call it "setfocus".

After WhereFocus.focus try adding (); and sometimes, some browsers will want you to put javascript: in front of the function call.

Code: Select all
function setfocus(WhereFocus){WhereFocus.focus();}

and

<body onLoad="javascript:setfocus(<%=WhereFocus%>);">
But really, there's no reason to have a function that only does one thing, so you might as well cut down you code by removing the jscript function and doing
Code: Select all
<body onLoad="javascript:<%=WhereFocus%>.focus();">
  #3 (permalink)  
Old Jan 5th, 2004, 22:28
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
took the words right outta my mouth!
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #4 (permalink)  
Old Jan 9th, 2004, 18:10
New Member
Join Date: Aug 2003
Location: USA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks!
Closed Thread

Tags
properties

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Height Properties defy Web Page Design 2 Oct 29th, 2007 13:23
Some properties are inherited begemot Web Page Design 3 May 19th, 2007 18:37
Getting properties of another file(ex.HTML)? markor2d2 JavaScript Forum 2 May 3rd, 2007 08:17
Xsd Xml Schema - Same Element With Different Properties myghty Other Programming Languages 0 Aug 6th, 2006 12:30
Changing properties of hyperlinks? tom_king88 Web Page Design 7 Jul 7th, 2006 19:58


All times are GMT. The time now is 22:29.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43