Object detection for <OBJECT> element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Thompson

    Object detection for <OBJECT> element

    This is intended to fix a long standing
    (cough)Java(cou gh) problem with which I'm
    sure some of you will be familiar.

    Sun recommends using the <OBJECT>/<EMBED>
    elements to cater for Java applets, but then
    uses *browser* *sniffing* Javascript to select
    between them.

    I was hoping to find/create a script that
    will use feature detection to write the
    appropriate tag, but I am stumped as to
    how to detect whether to use the OBJECT
    element or alternatively (& in actuality)
    the original APPLET* element.

    * I want to avoid invalid HTML as well,
    and the <EMBED> ..thing was never a valid
    HTML element, not in any HTML recommendation
    I can put my hands on, in any case.

    So, my immediate questions are..

    Is there a way to detect if a browser will understand
    the <OBJECT> element, using Javascript object detection?

    How?

    BTW.. I was playing with some experiments
    on 'nesting' the various elements, using no
    Javascript. They were rather unsuccessful,
    you can see them here..
    <http://www.physci.org/test/appletcall/>
    ...this post pretty much picks up where the
    'conclusion' of that page arrives.

    Appreciate any insights.

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
  • kaeli

    #2
    Re: Object detection for &lt;OBJECT&g t; element

    In article <1519awvue93l1$ .5ktypvyiy2be$. dlg@40tude.net> ,
    SeeMySites@www. invalid enlightened us with...[color=blue]
    >
    > Is there a way to detect if a browser will understand
    > the <OBJECT> element, using Javascript object detection?
    >[/color]

    Why would you?
    From <http://www.ibiblio.org/javafaq/course/week5/14.html>
    [cite]
    You can support both by placing an <APPLET> element inside an <OBJECT>
    element like this:

    <OBJECT classid="MyAppl et" width="200" height="200">
    <APPLET code="MyApplet" width="200" height="200">
    </APPLET>
    </OBJECT>

    Browsers that understand <OBJECT> will ignore its content while browsers that
    don't will display its content.
    [/cite]

    --
    --
    ~kaeli~
    If the funeral procession is at night, do folks drive with
    their lights off?



    Comment

    • kaeli

      #3
      Re: Object detection for &lt;OBJECT&g t; element

      In article <1519awvue93l1$ .5ktypvyiy2be$. dlg@40tude.net> ,
      SeeMySites@www. invalid enlightened us with...[color=blue]
      >
      > Is there a way to detect if a browser will understand
      > the <OBJECT> element, using Javascript object detection?
      >[/color]

      Oh, and I would imagine that any browser that supports the new DOM will
      support the object tag. So give it an ID and test for

      if (document.getEl ementById && document.getEle mentById("myObj ectId"))

      If I'm wrong on that, someone let me know, mmkay?

      --
      --
      ~kaeli~
      If the funeral procession is at night, do folks drive with
      their lights off?



      Comment

      • Andrew Thompson

        #4
        Re: Object detection for &lt;OBJECT&g t; element

        On Fri, 20 Aug 2004 09:44:02 -0500, kaeli wrote:
        [color=blue]
        > <OBJECT classid="MyAppl et" width="200" height="200">
        > <APPLET code="MyApplet" width="200" height="200">
        > </APPLET>
        > </OBJECT>[/color]

        That is essentially what I attempted here..
        <http://www.physci.org/test/appletcall/index1.html>

        Did I do it wrong? (IE 6 renders both calls.)

        --
        Andrew Thompson
        http://www.PhySci.org/ Open-source software suite
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.1point1C.org/ Science & Technology

        Comment

        • Martin Honnen

          #5
          Re: Object detection for &lt;OBJECT&g t; element



          Andrew Thompson wrote:
          [color=blue]
          > On Fri, 20 Aug 2004 09:44:02 -0500, kaeli wrote:
          >
          >[color=green]
          >><OBJECT classid="MyAppl et" width="200" height="200">
          >><APPLET code="MyApplet" width="200" height="200">
          >></APPLET>
          >></OBJECT>[/color]
          >
          >
          > That is essentially what I attempted here..
          > <http://www.physci.org/test/appletcall/index1.html>
          >
          > Did I do it wrong? (IE 6 renders both calls.)[/color]

          No, nothing wrong with your HTML but IE does the wrong thing with
          content of an <object> element.

          --

          Martin Honnen

          Comment

          • kaeli

            #6
            Re: Object detection for &lt;OBJECT&g t; element

            In article <y72hx3jnrwlt.1 2r4samevwa9i.dl g@40tude.net>,
            SeeMySites@www. invalid enlightened us with...[color=blue]
            > On Fri, 20 Aug 2004 09:44:02 -0500, kaeli wrote:
            >[color=green]
            > > <OBJECT classid="MyAppl et" width="200" height="200">
            > > <APPLET code="MyApplet" width="200" height="200">
            > > </APPLET>
            > > </OBJECT>[/color]
            >
            > That is essentially what I attempted here..
            > <http://www.physci.org/test/appletcall/index1.html>
            >
            > Did I do it wrong? (IE 6 renders both calls.)
            >
            >[/color]

            I dunno...what should it look like that makes you think it isn't doing what
            it's supposed to do?
            I see the applet in my IE6. Once.
            Note that I always have the latest version of IE with all patches and the
            latest SP for my OS, which is Win2K Pro here at work and WinXP at home. My
            default browser is Netscape 7 and my JVM is 1.4.1. I am a java developer, so
            I have the whole SDK installed.

            Java(TM) Plug-in: Version 1.4.1_01
            Using JRE version 1.4.1_01 Java HotSpot(TM) Client VM

            --
            --
            ~kaeli~
            A midget fortune teller who escapes from prison is a small
            medium at large.



            Comment

            • Andrew Thompson

              #7
              Re: Object detection for &lt;OBJECT&g t; element

              On Fri, 20 Aug 2004 17:34:12 +0200, Martin Honnen wrote:[color=blue]
              > Andrew Thompson wrote:[color=green]
              >> On Fri, 20 Aug 2004 09:44:02 -0500, kaeli wrote:
              >>[color=darkred]
              >>><OBJECT classid="MyAppl et" width="200" height="200">
              >>><APPLET code="MyApplet" width="200" height="200">
              >>></APPLET>
              >>></OBJECT>[/color]
              >>
              >> That is essentially what I attempted here..
              >> <http://www.physci.org/test/appletcall/index1.html>
              >>
              >> Did I do it wrong? (IE 6 renders both calls.)[/color]
              >
              > No, nothing wrong with your HTML but IE does the wrong thing with
              > content of an <object> element.[/color]

              I suppose that is what I have been skirting around..
              (I didn't intend coming in here screaming about how
              'I need to detect IE'!)

              I figure it is better to try and detect if
              the *browser* supports the <OBJECT> element
              and use it, otherwise write the applet tag.

              So, that brings us back to the starting point..

              Is there a way to detect whether a browser will
              accept act/on the <OBJECT> element?

              --
              Andrew Thompson
              http://www.PhySci.org/ Open-source software suite
              http://www.PhySci.org/codes/ Web & IT Help
              http://www.1point1C.org/ Science & Technology

              Comment

              • Andrew Thompson

                #8
                Re: Object detection for &lt;OBJECT&g t; element

                On Fri, 20 Aug 2004 10:37:47 -0500, kaeli wrote:
                [color=blue]
                > I see the applet in my IE6. Once.[/color]

                The page is a bit quirky I have noticed
                (do not know why), sometimes the label
                OBJECT will appear to the left of the label
                APPLET.. each is configured for the respective
                call to the applet.

                On other occasions, frustratingly, the page will show
                only the APPLET message, but still leaves the space
                where the OBJECT label *would* have appeared.

                In contrast, Moz/NN both show the label APPLET,
                on the left, while Opera shows OBJECT on the left.

                Most confounding.. :-(

                --
                Andrew Thompson
                http://www.PhySci.org/ Open-source software suite
                http://www.PhySci.org/codes/ Web & IT Help
                http://www.1point1C.org/ Science & Technology

                Comment

                • kaeli

                  #9
                  Re: Object detection for &lt;OBJECT&g t; element

                  In article <1ukbkf1ahx1p9. 1srphdyt3750z.d lg@40tude.net>,
                  SeeMySites@www. invalid enlightened us with...[color=blue]
                  > and use it, otherwise write the applet tag.
                  >
                  > So, that brings us back to the starting point..
                  >
                  > Is there a way to detect whether a browser will
                  > accept act/on the <OBJECT> element?
                  >
                  >[/color]

                  But you see, IE would report that it did support it. It thinks it does.
                  The implementation is buggy, but the browser thinks it has it.

                  So, in this case, I'd recommend IE conditional comments if you're having
                  problems specifically with IE. AFAIK, older non-IE browsers that don't
                  support the object tag will indeed ignore the object tag and use the applet
                  tag, as they should.

                  Oh, and for some reason, now I DO see both elemenets. I had to refresh the
                  page a couple times.

                  --
                  --
                  ~kaeli~
                  If it's tourist season, why can't we shoot them?



                  Comment

                  • kaeli

                    #10
                    Re: Object detection for &lt;OBJECT&g t; element

                    In article <k990gez1ohmj.1 6vwut0x748rl.dl g@40tude.net>,
                    SeeMySites@www. invalid enlightened us with...[color=blue]
                    > On Fri, 20 Aug 2004 10:37:47 -0500, kaeli wrote:
                    >[color=green]
                    > > I see the applet in my IE6. Once.[/color]
                    >
                    > The page is a bit quirky I have noticed
                    > (do not know why), sometimes the label
                    > OBJECT will appear to the left of the label
                    > APPLET.. each is configured for the respective
                    > call to the applet.
                    >[/color]

                    Yeah, I noticed after I refreshed that I DID see the object, too.

                    Very odd.
                    See my other reply about conditional comments for IE.

                    --
                    --
                    ~kaeli~
                    A little rudeness and disrespect can elevate a meaningless
                    interaction to a battle of wills and add drama to an
                    otherwise dull day.



                    Comment

                    • Randy Webb

                      #11
                      Re: Object detection for &lt;OBJECT&g t; element

                      kaeli wrote:[color=blue]
                      > In article <1519awvue93l1$ .5ktypvyiy2be$. dlg@40tude.net> ,
                      > SeeMySites@www. invalid enlightened us with...
                      >[color=green]
                      >>Is there a way to detect if a browser will understand
                      >>the <OBJECT> element, using Javascript object detection?
                      >>[/color]
                      >
                      >
                      > Oh, and I would imagine that any browser that supports the new DOM will
                      > support the object tag. So give it an ID and test for
                      >
                      > if (document.getEl ementById && document.getEle mentById("myObj ectId"))
                      >
                      > If I'm wrong on that, someone let me know, mmkay?
                      >[/color]

                      <mytag id="myID">Text </mytag>
                      <button onclick="
                      if (document.getEl ementById &&
                      document.getEle mentById('myID' )){alert('Yes') }">Test</button>

                      IE6 gives the alert, even though it doesn't understand the "mytag".

                      Testing for the ID will only tell you whether it exists or not, not
                      whether it supports the tag or not.

                      About the only way to test for support of the OBJECT tag would be to try
                      to load some data file in it, read it and see what your results are.

                      Changing the above alert to:
                      document.getEle mentById('myID' ).innerHTML;
                      IE6 gives a blank alert. Means it finds the ID but can't read its
                      innerHTML property since it doesn't actually support the mytag tag.

                      --
                      Randy
                      comp.lang.javas cript FAQ - http://jibbering.com/faq

                      Comment

                      • Michael Winter

                        #12
                        Re: Object detection for &lt;OBJECT&g t; element

                        On Fri, 20 Aug 2004 16:01:18 GMT, Andrew Thompson <SeeMySites@www .invalid>
                        wrote:
                        [color=blue]
                        > On Fri, 20 Aug 2004 10:37:47 -0500, kaeli wrote:
                        >[color=green]
                        >> I see the applet in my IE6. Once.[/color]
                        >
                        > The page is a bit quirky I have noticed
                        > (do not know why), sometimes the label
                        > OBJECT will appear to the left of the label
                        > APPLET.. each is configured for the respective
                        > call to the applet.[/color]

                        Quirky? When I first loaded the page, there was a space for the OBJECT
                        element (the applet was there but not started), and APPLET was shown.
                        However, IE crashed.

                        The second time, the same, but without the crash. A null pointer
                        exception, and a permission denied error.

                        The third time, success with both.

                        IE 6, SP2. WinXP SP1.

                        [snip]

                        On the actual topic: I don't think so. There's certainly no direct way. I
                        considered using document.create Element() (I know it would be useless for
                        NN4 and the like) to create an OBJECT, but Mozilla has no problem creating
                        it (OBJECT isn't just used for applets, after all).

                        By the way, EMBED has never been a standard element. The first OBJECT-like
                        element was APPLET, introduced in HTML 3.2, followed by OBJECT sometime in
                        HTML 4 (forgive me for not looking up exactly when). EMBED is just made up
                        Microsoft rubbish.

                        Sorry I couldn't help more,
                        Mike

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

                        Comment

                        • Richard Cornford

                          #13
                          Re: Object detection for &lt;OBJECT&g t; element

                          Andrew Thompson wrote:[color=blue]
                          > Martin Honnen wrote:[color=green]
                          >> Andrew Thompson wrote:[/color][/color]
                          <snip>[color=blue][color=green][color=darkred]
                          >>> That is essentially what I attempted here..
                          >>> <http://www.physci.org/test/appletcall/index1.html>
                          >>>
                          >>> Did I do it wrong? (IE 6 renders both calls.)[/color]
                          >>
                          >> No, nothing wrong with your HTML but IE does the wrong
                          >> thing with content of an <object> element.[/color]
                          >
                          > I suppose that is what I have been skirting around..
                          > (I didn't intend coming in here screaming about how
                          > 'I need to detect IE'!)
                          >
                          > I figure it is better to try and detect if
                          > the *browser* supports the <OBJECT> element
                          > and use it, otherwise write the applet tag.
                          >
                          > So, that brings us back to the starting point..
                          >
                          > Is there a way to detect whether a browser will
                          > accept act/on the <OBJECT> element?[/color]

                          My IE 6 puts up the security warning about my having ActiveX disabled
                          and then shows the APPLET label, but I will believe that it would show
                          both if ActiveX was enabled (it won't be), and
                          document.getEle mentsByTagName( 'object).length returned one, while
                          document.applet s.length returned two. But if both exist you should be
                          able to test for that condition and remove one of them from the DOM.

                          For example, if you put a script element immediately after the
                          OBJECT/APPLET tags and try to see if one, then the other, can be
                          accessed through the DOM (by ID or in the pertinent collection) if you
                          find you have both the browser is probably IE and it should support the
                          removal of one of them form the DOM ( -
                          appletX.partneN ode.removeChild (appletX)) - ). That should happen quickly
                          enough that the user wouldn't notice.

                          In the case of my disabled ActiveX it would be best to remove the
                          disabled one rather than the working one.

                          Richard.


                          Comment

                          • Andrew Thompson

                            #14
                            Re: Object detection for &lt;OBJECT&g t; element

                            On Fri, 20 Aug 2004 11:14:42 -0500, kaeli wrote:[color=blue]
                            > In article <k990gez1ohmj.1 6vwut0x748rl.dl g@40tude.net>,
                            > SeeMySites@www. invalid enlightened us with...[color=green]
                            >> On Fri, 20 Aug 2004 10:37:47 -0500, kaeli wrote:
                            >>[color=darkred]
                            >>> I see the applet in my IE6. Once.[/color]
                            >>
                            >> The page is a bit quirky I have noticed[/color][/color]
                            ...[color=blue]
                            > Yeah, I noticed after I refreshed that I DID see the object, too.[/color]
                            ...[color=blue]
                            > See my other reply about conditional comments for IE.[/color]

                            Yeah.. IE conditional statements seemed a promising
                            avenue. I had a look at them, but simply could
                            not come up with a combination that worked to
                            hide one applet call from IE, while allowing
                            Netscape/Mozilla & Opera to see both..

                            Do you have any specific inspirations in that regard?
                            I will look at the IE conditional statements again
                            if I can get a new angle to attack it..

                            --
                            Andrew Thompson
                            http://www.PhySci.org/ Open-source software suite
                            http://www.PhySci.org/codes/ Web & IT Help
                            http://www.1point1C.org/ Science & Technology

                            Comment

                            • Randy Webb

                              #15
                              Re: Object detection for &lt;OBJECT&g t; element

                              Richard Cornford wrote:
                              [color=blue]
                              > Andrew Thompson wrote:
                              >[color=green]
                              >>Martin Honnen wrote:
                              >>[color=darkred]
                              >>>Andrew Thompson wrote:[/color][/color]
                              >
                              > <snip>
                              >[color=green][color=darkred]
                              >>>>That is essentially what I attempted here..
                              >>>><http://www.physci.org/test/appletcall/index1.html>
                              >>>>
                              >>>>Did I do it wrong? (IE 6 renders both calls.)
                              >>>
                              >>>No, nothing wrong with your HTML but IE does the wrong
                              >>>thing with content of an <object> element.[/color]
                              >>
                              >>I suppose that is what I have been skirting around..
                              >>(I didn't intend coming in here screaming about how
                              >>'I need to detect IE'!)
                              >>
                              >>I figure it is better to try and detect if
                              >>the *browser* supports the <OBJECT> element
                              >>and use it, otherwise write the applet tag.
                              >>
                              >>So, that brings us back to the starting point..
                              >>
                              >>Is there a way to detect whether a browser will
                              >>accept act/on the <OBJECT> element?[/color]
                              >
                              >
                              > My IE 6 puts up the security warning about my having ActiveX disabled
                              > and then shows the APPLET label, but I will believe that it would show
                              > both if ActiveX was enabled (it won't be), and
                              > document.getEle mentsByTagName( 'object).length returned one, while
                              > document.applet s.length returned two. But if both exist you should be
                              > able to test for that condition and remove one of them from the DOM.
                              >
                              > For example, if you put a script element immediately after the
                              > OBJECT/APPLET tags and try to see if one, then the other, can be
                              > accessed through the DOM (by ID or in the pertinent collection) if you[/color]

                              Not by ID, but through the collection. It will find it by ID, even if it
                              doesn't support the tag. See my other reply in this thread.



                              --
                              Randy
                              comp.lang.javas cript FAQ - http://jibbering.com/faq

                              Comment

                              Working...