Javascript & OS... Question ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Florian Proch

    Javascript & OS... Question ?

    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="Javas cript" for="window" event="onload() ">
    if( navigator.userA gent.indexOf("O pera") != -1 ){
    setTimeout("doc ument.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
  • Martin Honnen

    #2
    Re: Javascript &amp; OS... Question ?



    Florian Proch wrote:

    [color=blue]
    > i have
    > write a javascript who make a automatic submit when the page is
    > reload.
    >
    > <script language="Javas cript" for="window" event="onload() ">
    > if( navigator.userA gent.indexOf("O pera") != -1 ){
    > setTimeout("doc ument.forms[0].elements['btValider'].click();",1000 );
    > }
    > else{
    > document.forms[0].submit();
    > }
    > </script>[/color]

    <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="loadHan dler(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.


    --

    Martin Honnen


    Comment

    • Richard Cornford

      #3
      Re: Javascript &amp; OS... Question ?

      Florian Proch wrote:[color=blue]
      > i'm currently working for a big project to construct a website.
      >
      > We need to support some browser and OS :[/color]

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

      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.
      [color=blue]
      > Netscape 4.75 -> NS 7.2, Safari[/color]

      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.
      [color=blue]
      > and for OS : Win95/98/NT/Me/2000/XP, MacOS 9/10, Linux.[/color]

      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)?
      [color=blue]
      > 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="Javas cript" for="window" event="onload() ">[/color]

      Martin has already explained why that SCRIPT tag is not going to be
      useful.
      [color=blue]
      > if( navigator.userA gent.indexOf("O pera") != -1 ){[/color]

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

      <URL: http://jibbering.com/faq/faq_notes/n...er_detect.html >
      [color=blue]
      > setTimeout("doc ument.forms[0].elements['btValider'].click();",
      > 1000);
      > } else{
      > document.forms[0].submit();
      > }
      > </script>[/color]

      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.
      [color=blue]
      > 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 :)[/color]

      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.javas cript 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.


      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Javascript &amp; OS... Question ?

        florian.proch@a ccenture.com (Florian Proch) writes:
        [color=blue]
        > <script language="Javas cript" for="window" event="onload() ">[/color]

        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
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Javascript &amp; OS... Question ?

          Martin Honnen wrote:[color=blue]
          > Florian Proch wrote:[color=green]
          >> i have
          >> write a javascript who make a automatic submit when the page is
          >> reload.
          >>
          >> <script language="Javas cript" for="window" event="onload() ">
          >> if( navigator.userA gent.indexOf("O pera") != -1 ){
          >> setTimeout("doc ument.forms[0].elements['btValider'].click();",1000 );
          >> }
          >> else{
          >> document.forms[0].submit();
          >> }
          >> </script>[/color]
          >
          > <script for... event...
          > is something MS invented for IE but other browsers do not support that
          > usually, [...][/color]

          "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

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Javascript &amp; OS... Question ?

            Thomas 'Ingrid' Lahn wrote:[color=blue]
            > Martin Honnen wrote:[color=green]
            >> Florian Proch wrote:[color=darkred]
            >>> [...]
            >>> <script language="Javas cript" for="window" event="onload() ">
            >>> [...][/color]
            >>
            >> <script for... event...
            >> is something MS invented for IE but other browsers do not support that
            >> usually, [...][/color]
            >
            > "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. [...][/color]

            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

            Comment

            Working...