Javascript & OS... Question ?

F

Florian Proch

Hi all...
i'm currently working for a big project to construct a website.

We need to support some browser and OS : IE 5.0 -> IE 6, Mozilla 1.2
-> 1.7, Opera 5 -> Opéra 7.5x, Netscape 4.75 -> NS 7.2, Safari
and for OS : Win95/98/NT/Me/2000/XP, MacOS 9/10, Linux.

I have some problems with browser on different OS. For example i have
write a javascript who make a automatic submit when the page is
reload.

<script language="Javascript" for="window" event="onload()">
if( navigator.userAgent.indexOf("Opera") != -1 ){
setTimeout("document.forms[0].elements['btValider'].click();",1000);
}
else{
document.forms[0].submit();
}
</script>

This work fine on XP with Mozilla 1.6 but when i try Mozilla 1.6 on
Win98 or NT , i have no refresh and i need to click to the submit
button to send the form....

I'm searching the dependencies between Javascript and OS( or Browser
in different OS ). Someone can help me ??
All infos is accepted :)

Thanks
Regards
Florian Proch
 
M

Martin Honnen

Florian Proch wrote:

i have
write a javascript who make a automatic submit when the page is
reload.

<script language="Javascript" for="window" event="onload()">
if( navigator.userAgent.indexOf("Opera") != -1 ){
setTimeout("document.forms[0].elements['btValider'].click();",1000);
}
else{
document.forms[0].submit();
}
</script>

<script for... event...
is something MS invented for IE but other browsers do not support that
usually, only Netscape 7.1 has some support for that on Windows I think
to allow scripting of Windows Media Player.
If you want to have an onload handler then you should use
<script type="text/javascript">
function loadHandler (evt) {
// your code to be executed onload goes here
}
</script>
...
<body onload="loadHandler(event);">
That should call the function with at least Netscape 4, 6/7, Mozilla,
Opera 6/7, IE 4/5/6, I can't say what Opera 5 did.
 
R

Richard Cornford

Florian said:
i'm currently working for a big project to construct a website.

We need to support some browser and OS :

For a web site supporting browsers would be a good idea :)
IE 5.0 -> IE 6, Mozilla 1.2 -> 1.7,
Opera 5 -> Opéra 7.5x,

I very much doubt that anyone is still using Opera 5 (and certainly
versions less than 5.12). Opera 5 -> Opera 7.5x will include the
extremely limited and buggy Opera 5.02. You will have your work cut out
getting much out of that one.
Netscape 4.75 -> NS 7.2, Safari

Netscape 6 versions were based on pre-release (0.9) versions of Mozilla.
They were unreliable and cranky and I would hope that everyone who
upgraded from Netscape 4 to 6 also moved on to the infinitely better
Netscape 7 versions when they became available.

Given that this list sets a minimum Mozilla version of 1.2 (and doesn't
mention Firefox at all) it doesn't seem like its creator knew much about
actual web browsers.
and for OS : Win95/98/NT/Me/2000/XP, MacOS 9/10, Linux.

Presumably this list of browsers features in some sort of specification
for the web site. Does the specification explicitly state javascript
enabled default configurations of the listed browsers or are you
expected to cope with all of there configuration permutations by
implication (including the option of turning javascript off)?
I have some problems with browser on different OS. For
example i have write a javascript who make a automatic
submit when the page is reload.

<script language="Javascript" for="window" event="onload()">

Martin has already explained why that SCRIPT tag is not going to be
useful.
if( navigator.userAgent.indexOf("Opera") != -1 ){

Don't do this. The - navigator.userAgent - string has no relationship
with the type or version of the browser (except by coincidence in a
limited number of cases):-

setTimeout("document.forms[0].elements['btValider'].click();",
1000);
} else{
document.forms[0].submit();
}
</script>

The automated submitting of forms can be disabled by configuration in
some of your listed browsers, and is also one of the things that can be
barred by content inserting/re-writing proxies (personal firewalls,
Internet security programmes, some types of advertising blockers, etc.).

However, submitting a form implies some sort of server-side scripting in
order to be useful. And automatically submitting a form as the page
loads implies that the form data is not going to be filled in by the
user but is pre-filled in (probably by a server-side script). Making
this no more than a mechanism for passing data around. As such it is
almost certainly the wrong way of doing this. There are many alternative
methods, but without knowing why you are attempting this in the first
palace (and the full context) it is impossible to suggest any one.
This work fine on XP with Mozilla 1.6 but when i try
Mozilla 1.6 on Win98 or NT , i have no refresh and i
need to click to the submit button to send the form....

I'm searching the dependencies between Javascript and
OS( or Browser in different OS ). Someone can help me ??
All infos is accepted :)

Javascript was standardised by the ECMA and all of browsers you list
implement, at minimum, a fairly consistent version of ECMA 262 2nd
edition (most implementing the 3rd edition).

On the other hand, the DOMs of the browsers listed vary enormously. You
have the very un-dynamic Opera <= 6, with minimal scriptable style
support and an incomplete W3C level 1 DOM. You have the monstrosity that
was Netscape 4, with its totally different approach to dynamic content
and extremely limited DOM. And then you have the latest all singing and
dancing Mozilla versions.

Unfortunate, on the evidence of what you have posted here as code and as
a question, I suspect that you are completely out of your depth. And are
probably 6 months of intensive research, experimentation and
cross-browser scripting, away from being able to cope with this project
well. In the meanwhile trying to learn 'on the job' will leave you
thrashing about (mostly ineffectually) putting code that is objectively
bad into a production web site at someone else's expense.

Assuming that you don't have the option of hiring someone who already
has the skills needed for the job, and that you actually care to be
doing the best job you are capable of doing for your client, you are
going to need a lot of help. You will be able to get some of that help
from comp.lang.javascript as the group has a distinct bias towards
cross-browser scripting, but you are going to have to optimise you
interactions with the group and put a lot of work in yourself. First
locate, read and familiarise yourself with the group's FAQ:-

<URL: http://jibbering.com/faq/ >

- paying particular attention to the advice on efficiently asking
questions that is linked to from section 2.3, and becoming familiar with
what is available at the various resources listed.

Richard.
 
L

Lasse Reichstein Nielsen

<script language="Javascript" for="window" event="onload()">

As Martin Honnen said, this is your problem.
My suggestion for avoiding such problems is to make sure your HTML
validates. That should increase your chance of everything working.

/L
 
T

Thomas 'PointedEars' Lahn

Martin said:
Florian said:
i have
write a javascript who make a automatic submit when the page is
reload.

<script language="Javascript" for="window" event="onload()">
if( navigator.userAgent.indexOf("Opera") != -1 ){
setTimeout("document.forms[0].elements['btValider'].click();",1000);
}
else{
document.forms[0].submit();
}
</script>

<script for... event...
is something MS invented for IE but other browsers do not support that
usually, [...]

"event" (CDATA) and "for" (%URI) are attributes of the "script" element
defined in the HTML 4.01 Transitional and Strict DTDs but marked (by comment
only!) "reserved for possible future use", so no UA is required to implement
it. IE does and I would consider this a Good Thing as this follows the
standard. The main problem here is the missing "type" attribute which is
the only thing that makes this not Valid HTML, although IE really seems to
be the only UA to support the "event" and "for" attributes for the "script"
element (no matter where in the document it is located).

However, both attributes are not present in the XHTML 1.0 DTDs,
so apparently the arguments for the announced reservations "for
possible future use" were not sound enough to include them in
that XML reformulation of HTML.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Thomas said:
Martin said:
Florian said:
[...]
<script language="Javascript" for="window" event="onload()">
[...]

<script for... event...
is something MS invented for IE but other browsers do not support that
usually, [...]

"event" (CDATA) and "for" (%URI) are attributes of the "script" element
defined in the HTML 4.01 Transitional and Strict DTDs but marked (by comment
only!) "reserved for possible future use", so no UA is required to implement
it. IE does and I would consider this a Good Thing as this follows the
standard. [...]

But even then the value of the "event" attribute must be the name of
an intrinsic event handler, that is, the parantheses must be omitted.
And the value of "for" must then be the ID of an element within the
document, not the identifier of a DOM object as seen here. I have
already mentioned the "type" attribute issue.


PointedEars
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top