Problems with Opera

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Richardson

    #1

    Problems with Opera

    In http://www.writeonwhidbey.org/_private/ssi/ssitest.html I have a simple
    function

    <script language="JavaS cript1.2" style="text/javascript">
    <!--
    function checkLocation() {
    if (navigator.user Agent.indexOf(" Opera")!=-1) type="OP"
    else if (document.all) type="IE" // ie 4 & up
    else type="XX"
    if (type=="IE")
    moveNav.style.p ixelTop=documen t.documentEleme nt.scrollTop
    setTimeout("che ckLocation()",5 );
    }
    //-->
    </script>

    This is suppose to keep the Nav bar at the top of an IE browser. (Yes, it
    wobbles a little bit, but what can I do?)

    With most other browsers, the Nav Bar stays nice and stationary at the top,
    thanks to a nice CSS solution. However, with Opera (at least Opera 7.54 that
    I have) the nav bar wobbles a bit like I would expect it to in IE, but still
    it gets hidden under most scrolling situations. What's the cure for Opera?

    TIA

    p/s/ I also tried:
    if (navigator.user Agent.indexOf(" Opera")!=-1
    && document.getEle mentById) type="OP";

    but did the same thing.



  • Michael Winter

    #2
    Re: Problems with Opera

    On 18/04/2005 18:30, Bob Richardson wrote:

    [snip]
    [color=blue]
    > <script language="JavaS cript1.2" style="text/javascript">[/color]

    Specifying the language attribute is at best, redundant. Specifying
    the language attribute as JavaScript1.2 can be positively dangerous as
    far as reliable execution is concerned. Remove it.
    [color=blue]
    > <!--[/color]

    Remove the SGML comment delimiters. They are unnecessary (have been
    for years).

    [snip]
    [color=blue]
    > if (type=="IE")[/color]

    If you really want this executed by IE only, then use conditional
    comments (either JScript, or HTML) to hide the code from other user
    agents. It is far more reliable than browser detection. You can search
    the MSDN Library (<URL:http://msdn.microsoft. com/>) for both.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Bob Richardson

      #3
      Re: Problems with Opera

      After reading up on Conditional Comments, it appeared that this coding would
      work, allowing the JS to work only with IE 5 and up.

      <!--[if IE gte 5]>
      <SCRIPT LANGUAGE="Javas cript">
      function checkLocation() {
      moveNav.style.p ixelTop=documen t.documentEleme nt.scrollTop
      setTimeout("che ckLocation()",5 );
      }
      </SCRIPT>
      <![endif]-->

      Works for NS and Firefox. In IE 6 "<!-- ->" appears at the top of
      the nav bar, and in Opera, the Nav bar scrolls up when you scroll down!!
      What am I missing!


      "Michael Winter" <m.winter@bluey onder.co.invali d> wrote in message
      news:ouS8e.1492 6$G8.9401@text. news.blueyonder .co.uk...[color=blue]
      > On 18/04/2005 18:30, Bob Richardson wrote:
      >
      > [snip]
      >[color=green]
      >> <script language="JavaS cript1.2" style="text/javascript">[/color]
      >
      > Specifying the language attribute is at best, redundant. Specifying the
      > language attribute as JavaScript1.2 can be positively dangerous as far as
      > reliable execution is concerned. Remove it.
      >[color=green]
      >> <!--[/color]
      >
      > Remove the SGML comment delimiters. They are unnecessary (have been for
      > years).
      >
      > [snip]
      >[color=green]
      >> if (type=="IE")[/color]
      >
      > If you really want this executed by IE only, then use conditional comments
      > (either JScript, or HTML) to hide the code from other user agents. It is
      > far more reliable than browser detection. You can search the MSDN Library
      > (<URL:http://msdn.microsoft. com/>) for both.
      >
      > [snip]
      >
      > Mike
      >
      > --
      > Michael Winter
      > Replace ".invalid" with ".uk" to reply by e-mail.[/color]


      Comment

      • Bob Richardson

        #4
        Re: Problems with Opera

        I see I misplaced the gte. This coding still does not work. Opera sees it
        and it appears that IE doesn't!!

        <!--[if gte IE 5]>
        <SCRIPT LANGUAGE="Javas cript">
        function checkLocation() {
        moveNav.style.p ixelTop=documen t.documentEleme nt.scrollTop
        setTimeout("che ckLocation()",5 ­);
        }
        </SCRIPT>
        <![endif]-->

        "Bob Richardson" <bobr at whidbey dot com> wrote in message
        news:WbadnRACmL NbvvnfRVn-uQ@whidbeytel.c om...[color=blue]
        > After reading up on Conditional Comments, it appeared that this coding
        > would work, allowing the JS to work only with IE 5 and up.
        >
        > <!--[if IE gte 5]>
        > <SCRIPT LANGUAGE="Javas cript">
        > function checkLocation() {
        > moveNav.style.p ixelTop=documen t.documentEleme nt.scrollTop
        > setTimeout("che ckLocation()",5 );
        > }
        > </SCRIPT>
        > <![endif]-->
        >
        > Works for NS and Firefox. In IE 6 "<!-- ->" appears at the top of
        > the nav bar, and in Opera, the Nav bar scrolls up when you scroll down!!
        > What am I missing!
        >
        >
        > "Michael Winter" <m.winter@bluey onder.co.invali d> wrote in message
        > news:ouS8e.1492 6$G8.9401@text. news.blueyonder .co.uk...[color=green]
        >> On 18/04/2005 18:30, Bob Richardson wrote:
        >>
        >> [snip]
        >>[color=darkred]
        >>> <script language="JavaS cript1.2" style="text/javascript">[/color]
        >>
        >> Specifying the language attribute is at best, redundant. Specifying the
        >> language attribute as JavaScript1.2 can be positively dangerous as far as
        >> reliable execution is concerned. Remove it.
        >>[color=darkred]
        >>> <!--[/color]
        >>
        >> Remove the SGML comment delimiters. They are unnecessary (have been for
        >> years).
        >>
        >> [snip]
        >>[color=darkred]
        >>> if (type=="IE")[/color]
        >>
        >> If you really want this executed by IE only, then use conditional
        >> comments (either JScript, or HTML) to hide the code from other user
        >> agents. It is far more reliable than browser detection. You can search
        >> the MSDN Library (<URL:http://msdn.microsoft. com/>) for both.
        >>
        >> [snip]
        >>
        >> Mike
        >>
        >> --
        >> Michael Winter
        >> Replace ".invalid" with ".uk" to reply by e-mail.[/color]
        >
        >[/color]


        Comment

        • Stephen Chalmers

          #5
          Re: Problems with Opera

          Bob Richardson <bobr at whidbey dot com> wrote in message
          news:uK2dnYIiLr sFqfnfRVn-jA@whidbeytel.c om...[color=blue]
          > I see I misplaced the gte. This coding still does not work. Opera sees it
          > and it appears that IE doesn't!!
          >
          > <!--[if gte IE 5]>
          > <SCRIPT LANGUAGE="Javas cript">
          > function checkLocation() {
          > moveNav.style.p ixelTop=documen t.documentEleme nt.scrollTop
          > setTimeout("che ckLocation()",5 ­);
          > }
          > </SCRIPT>
          > <![endif]-->
          >[/color]

          Opera 7.54 does not "see" this code as it is effectively within conventional
          comments. If you enable error reporting, you will see this causes an error
          when the non-existent function is called onload:

          <body onLoad="checkLo cation()">

          Having said that, It appears that you have just trashed the code. Perhaps
          for the best...
          --
          Stephen Chalmers




          Comment

          Working...