Re: Someone dropped a job into my lap



Helmut Giese wrote:

> I have listed some basic questions below and I am hoping someone will
> be able to provide some links ot other information answering those.
>
> 1) What is the current version of javascript which is supported by the
> current browsers (or is this a no-issue)?

Define 'current browsers'. Are you developing for an intranet, when you
might reasonably be able to control which browsers are used, or the
internet when you can't. If its the latter, it is up to you to decide how
far back in time to go.

I would suggest as a general rule assume ECMAScript Language Specification
3rd edition (December 1999),
http://www.ecma-international.org/publications/standards/Ecma-262.htm

but remember that none of the browsers actually implement the standard
correctly.

>
> 2) A reference of pre-defined objects and their properties /
> functions.

Try starting with
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_e
ntry.asp

at the bottom of each description of an object or property there is a
section 'standards information'. Avoid touching anything which is marked as
not being standard unless you have no choice. Use sites such as
http://www.quirksmode.org/ to find out how to handle differences between
browsers.

>
> 3) How do you debug javascript? If you make an error, wrong HTML might
> show up (this could give you a clue) but also nothing might show up at
> all - what do you do then? Stare at the code?

Always do your development first on Mozilla or Firefox with the Javascript
debugger installed (on Firefox it is an option when installing but isn't
installed by default). Get it working on Mozilla then immediately test on
IE, that way if it doesn't work you only have a few possible lines to
search for the error.

You can also do debug style print statements on Firefox:

dump('just done whatever');

To see these you need to start Firefox with a console (on windows:
firefox.exe -console), although avoid firefox 1.5 beta for this as it
doesn't work.

On IE you can install Microsoft's script debugger (use this debugger only
as a last resort), or apparently it is possible to get the script debugger
from recent versions of Microsoft Office working instead. The main catch
here is that if you have ever had any of Microsoft's .net sdks installed,
and you aren't trying to debug a .net application, you need to make sure
that the 'machine debug manager' service is running mdm.exe from your
system folder, and not from 'Program Files\Common Files\Microsoft
Shared\VS7Debug'.

>
> 4) Libraries / collection of often used functions (handling of strings
> and dates, numeric stuff, etc.)
>
> 5) A side note: Is it possible in javascript to create variable names
> at runtime and access them? Something like (e.g. iterating over input
> fields)
> for (i=0; i< 10; ++i) {
> currField = <construct name of input field i here, e.g. inp0>
> currField.value = ...
> }
>
Creating variable names dynamically is never a good idea in any language.
What you actually want to do here is to reference the objects. Using global
variables isn't a good idea either: make sure all your local variables (I
hope 'i' is intended to be local) are declared using 'var'.

If you have a form with the name 'form1', and a field 'field1' then you can
access it as:

var field = document.forms['form1'].elements['field1'];
field.value = 'whatever';

Naturally you can iterate over the forms and elements collections. If you
do that you might not even care what the field names are:

var currentForm = document.forms['form1'];
var elements = currentForm.elements
for (var i=0; i < elements.length; ++i) {
var currField = elements[i];
if (currField.tagName=='INPUT' && currField.type=='text') {
currField.value = 'whatever';
};
};


> Any answers to the above questions or further helpful information will
> be greatly apprieciated.

If you believe in writing good code then I strongly recommend writing unit
tests. I use ecmaunit (from http://codespeak.net/svn/kupu/trunk/ecmaunit/)
or there is also jsunit (from http://www.edwardh.com/jsunit/)

Also, always write all your javascript in a separate file (or files) never
interleave javascript in the main html page.
.



Relevant Pages

  • Re: JavaScript Roguelike - Seeking input
    ... As is common knowledge, javascript isn't exactly the ... managed to do so in Firefox. ... in both Internet Explorer and Firefox, which are the only browsers ... the support of JavaScript 1.6 in Firefox gives ...
    (rec.games.roguelike.development)
  • Re: 10.4 and Javascript
    ... This has been a problem since installing 10.3 ... and affects all browsers, usually causing the browser to unexpectedly ... There was apparently an issue with 10.3 and javascript and applying the ...
    (uk.comp.sys.mac)
  • Re: hmm..interesting
    ... what browsers are there that are worth running on RISC OS? ... some sites that Netsurf can't. ... But of course not all Javascript stuff runs ... Firefox is simply too slow on an RPC. ...
    (comp.sys.acorn.hardware)
  • Re: hmm..interesting
    ... what browsers are there that are worth running on RISC OS? ... some sites that Netsurf can't. ... But of course not all Javascript stuff runs ... Firefox is simply too slow on an RPC. ...
    (comp.sys.acorn.hardware)
  • Re: Problem with Firefox?
    ... I have an XSL stylesheet that inserts some javascript in the ... Look at the Firefox Error Console. ... I think this is because you are putting your Javascript ... This was common in the days when some browsers ...
    (comp.text.xml)