firefox compatible javascript

B

bert76

can anyone suggest a couple of websites providing *compatible*
javascript?
of course there is
http://javascript.internet.com/
http://javascriptkit.com/
and the likes, but time and again you have to try out, test it only to
find it only works in IE.
at school, we want to test a number of javascripts, preferably
compatible with *all* browsers (mainly, but not just firefox).
tnx for suggestions
 
R

Randy Webb

bert76 said the following on 10/3/2005 8:15 AM:
can anyone suggest a couple of websites providing *compatible*
javascript?
of course there is
http://javascript.internet.com/
http://javascriptkit.com/

Neither of which is a good js site.
and the likes, but time and again you have to try out, test it only to
find it only works in IE.

That's typically what you get from copy-n-paste sites.
at school, we want to test a number of javascripts, preferably
compatible with *all* browsers (mainly, but not just firefox).
tnx for suggestions

Learn the language, write your own cross-browser scripts.
 
N

nikki

Grab a few that are easy to modify for FF use and modify them.
As long as they don't do anything too horrible that uses MSIE only
things that have no FF counterpart (which you usually don't see for
the web, anyway; you see that sort of thing for intranet apps), it's
not usually too hard.

Or go to dynamicdrive.com and make sure you look specifically for
cross-browser scripts.
 
R

Randy Webb

nikki said the following on 10/3/2005 3:31 PM:


Please quote what you are replying to, it makes following the
conversation easier.
Grab a few that are easy to modify for FF use and modify them.

In order to know what is "easy to modify for FF" it requires a level of
understanding that you wouldn't need to find copy/paste scripts, you
would already know how to write your own.
As long as they don't do anything too horrible that uses MSIE only
things that have no FF counterpart (which you usually don't see for
the web, anyway; you see that sort of thing for intranet apps), it's
not usually too hard.

And what about scripts that use non-IE code?
Or go to dynamicdrive.com and make sure you look specifically for
cross-browser scripts.

Dynamic Drive is just as bad, if not worse, than either of the ones
mentioned.
 
C

christopher.secord

bert76 said:
time and again you have to try out, test it only to
find it only works in IE.

A big part of the problem, I think, is that so much of what you find on
the web are hacks, instead of good well-written code. Most of it was
probably written years ago too. Take for example this:

<html>
<head>
<script>function a (){ alert(t.i.value) }</script>
</head>
<body>
<form name="t"><input name="i" onchange="a()"></form>
</body>

that works, but it's not valid html. If you change <html> to this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

then suddenly that code wont work. It wont work because it was invalid
all along - I'm supposed to use document.getElementById("i"), but if I
was just throwing together a hack for a tips website, maybe I wouldn't
care.

So you see, the problem isn't really compatibility. It's often
validity.
 
N

nikki

Randy said:
nikki said the following on 10/3/2005 3:31 PM:


Please quote what you are replying to, it makes following the
conversation easier.

Yeah, I forgot all about that.
I wish Google had both "reply" links quote.

(and look, people CAN remind me nicely...go figure)

Actually, I wish I had Gravity and a news server back, but the new job,
she blocks news servers and downloads.
In order to know what is "easy to modify for FF" it requires a level of
understanding that you wouldn't need to find copy/paste scripts, you
would already know how to write your own.

This is true.
And kind of what I was getting at, really.
Dynamic Drive is just as bad, if not worse, than either of the ones
mentioned.

Oh, I don't know.
It has some bad stuff, but I like a few of their cross-browser scripts.
Then again, some people are really picky. ;)

How about posting links to sites you think are good, then?
 
R

Randy Webb

(e-mail address removed) said the following on 10/3/2005 4:34 PM:
A big part of the problem, I think, is that so much of what you find on
the web are hacks, instead of good well-written code. Most of it was
probably written years ago too. Take for example this:

<html>
<head>
<script>function a (){ alert(t.i.value) }</script>
</head>
<body>
<form name="t"><input name="i" onchange="a()"></form>
</body>

that works, but it's not valid html. If you change <html> to this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

then suddenly that code wont work. It wont work because it was invalid
all along - I'm supposed to use document.getElementById("i"), but if I
was just throwing together a hack for a tips website, maybe I wouldn't
care.

No, you don't use getElementById to gain access to a form by its name.
You use the forms collection:

document.forms['formNAME'].elements['elementNAME'].value;

You went from one IE-only example to another IE-only example.
So you see, the problem isn't really compatibility. It's often
validity.

No, it's im/proper accessing that is the problem, along with validity
but more times than not, its crappy script writing.
 
R

Randy Webb

nikki said the following on 10/3/2005 4:51 PM:
Yeah, I forgot all about that.
I wish Google had both "reply" links quote.

(and look, people CAN remind me nicely...go figure)

I wish this were already in the FAQ though, it seems to be a major
problem for Google users:

<FAQENTRY>
If you want to post a followup via groups.google.com, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.
Actually, I wish I had Gravity and a news server back, but the new job,
she blocks news servers and downloads.




This is true.
And kind of what I was getting at, really.




Oh, I don't know.
It has some bad stuff, but I like a few of their cross-browser scripts.
Then again, some people are really picky. ;)

How about posting links to sites you think are good, then?

Personally, I have the same opinion that Jim Ley has. I don't like
canned copy/paste scripts. I would rather write a specific script for a
specific case.

But that aside, I honestly don't know of any "good" sites that have
copy/paste scripts.
 
R

Richard Cornford

A big part of the problem, I think, is that so much of what
you find on the web are hacks, instead of good well-written
code. Most of it was probably written years ago too.
Take for example this:

<html>
<head>
<script>function a (){ alert(t.i.value) }</script>
</head>
<body>
<form name="t"><input name="i" onchange="a()"></form>
</body>

As HTML 4 transitional the only invalid aspects of that mark-up appear
to be the absence of a TITLE element and a missing TYPE attribute in the
SCRIPT element. Neither of those errors would impact upon the behaviour
of the script in any real-world browsers.
that works,

Well, it doesn't. Assuming that a named form will be made available as a
named property of the global object is a bad habit aquifer because it is
true of IE browsers. It was never true of a significant proportion of
other browsers. That script never would have worked in a Netscape
browser, for example.
but it's not valid html. If you change <html> to this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

That is seriously disingenuous. Asking any script to survive the
transition from HTML to XHTML is very optimistic, as the XHTML DOM
requires a style of scripting that is very distinct from that required
for an HTML DOM. Asking HTML mark-up to successfully pass through an XML
parser is totally unrealistic.
then suddenly that code wont work.

Given that the original script was aimed at proprietary features of IE's
object model, and IE doesn't support/render XHTML at all, that isn't a
particularly unexpected change, though very few non-trivial scripts
would survive the transition form an HTML DOM to an XHTML DOM anyway.
It wont work because it was
invalid all along -

The invalidity in the original is not a factor in determining whether
that script would work or not.
I'm supposed to use document.getElementById("i"),

There are no elements in the original mark-up that have the ID "i", so
that would not be a useful change to make. The W3C HTML DOM specified
(and very back-compatible) - document.forms - collection is the place to
look-up forms by name (and/or ID, in W3C DOM implementations), and the -
elements - collection of the form is the place to look-up named (and/or
IDed, in W3C DOM implementations) form controls.

So you see, the problem isn't really compatibility.
It's often validity.

You haven't made your point at all. There are plenty of opportunities to
demonstrate invalid mark-up (particularly structurally invalid mark-up)
having a detrimental impact upon the scripted interaction with the
resulting DOM, particularly around the invalid placement of forms within
TABLE elements, but this 'example' is most likely to detract from a
case for the use of valid mark-up.

Richard.
 
G

Gérard Talbot

bert76 a écrit :
can anyone suggest a couple of websites providing *compatible*
javascript?

The thing is if you use web standards compliant DOM attributes and
methods, chances are your webpage will be working as expected on all
modern browsers.

Deprecated, rusted pages, full of invalid markup code and invalid CSS
code, full of poor, wrong coding practices, etc..
http://javascriptkit.com/
and the likes, but time and again you have to try out, test it only to
find it only works in IE.
Yep.

at school, we want to test a number of javascripts, preferably
compatible with *all* browsers (mainly, but not just firefox).
tnx for suggestions


Using Web Standards in Your Web Pages
(in particular the dom access section)
http://www.mozilla.org/docs/web-developer/upgrade_2.html

Mozilla Web Author FAQ
http://www.mozilla.org/docs/web-developer/faq.html

http://www.digital-web.com/articles/preparing_for_standard_compliant_browsers_part1/
http://www.digital-web.com/articles/preparing_for_standard_compliant_browsers_part2/

Making your web page compatible with Mozilla
(will show some differences in supported event object models)
http://www.reloco.com.ar/mozilla/compat.html

My website:
http://www.gtalbot.org/DHTMLSection/
will work for all modern browsers, although I have used hacks to
workaround incompatibilities

Gérard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top