js with <object> in xhtml strict

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Strandgaard

    #1

    js with <object> in xhtml strict

    There are no <iframe> tag in xhtml strict, instead I should use
    <object>.


    If I change <iframe> to <object> then my javascript stops working.
    I am curious to how to use <object> with javascript ?



    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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" xml:lang="en" lang="en">
    <head>
    <title>Test</title>
    <script type="text/javascript">
    function reload() {
    var el = document.getEle mentById("ifram e");
    el.contentWindo w.location.relo ad();
    }
    var timer = null;
    window.onload = function() {
    timer = setInterval(rel oad, 4000);
    }
    </script>
    </head>
    <body>
    <p>
    Before
    <iframe id="iframe" type="text/html" src="/content" width="330" height="57">
    Blah
    </iframe>
    After
    </p>
    </body></html>


    --
    Simon Strandgaard
  • Grant Wagner

    #2
    Re: js with &lt;object&g t; in xhtml strict

    Simon Strandgaard wrote:
    [color=blue]
    > There are no <iframe> tag in xhtml strict, instead I should use
    > <object>.
    >
    > If I change <iframe> to <object> then my javascript stops working.
    > I am curious to how to use <object> with javascript ?
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <!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" xml:lang="en" lang="en">
    > <head>
    > <title>Test</title>
    > <script type="text/javascript">
    > function reload() {
    > var el = document.getEle mentById("ifram e");
    > el.contentWindo w.location.relo ad();
    > }
    > var timer = null;
    > window.onload = function() {
    > timer = setInterval(rel oad, 4000);
    > }
    > </script>
    > </head>
    > <body>
    > <p>
    > Before
    > <iframe id="iframe" type="text/html" src="/content" width="330" height="57">
    > Blah
    > </iframe>
    > After
    > </p>
    > </body></html>
    >
    > --
    > Simon Strandgaard[/color]

    An <object> tag has no -src- attribute: <url:
    http://www.w3.org/TR/REC-html40/stru...ts.html#h-13.3 />. Even if it did,
    the <object> tag is not a window, so it doesn't have a -contentWindow-. The
    <object> tag does have a -data- attribute, you can probably make use of that
    fact.

    --
    Grant Wagner <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • Simon Strandgaard

      #3
      Re: js with &lt;object&g t; in xhtml strict

      Grant Wagner wrote:
      [color=blue]
      > Simon Strandgaard wrote:
      >[color=green]
      >> There are no <iframe> tag in xhtml strict, instead I should use
      >> <object>.
      >>
      >> If I change <iframe> to <object> then my javascript stops working.
      >> I am curious to how to use <object> with javascript ?[/color][/color]
      [snip xhtml]
      [color=blue]
      > An <object> tag has no -src- attribute: <url:
      > http://www.w3.org/TR/REC-html40/stru...ts.html#h-13.3 />. Even if it
      > did, the <object> tag is not a window, so it doesn't have a
      > -contentWindow-. The <object> tag does have a -data- attribute, you can
      > probably make use of that fact.[/color]


      I am curious if its possible to reload an <object>, when its xhtml strict?


      I have tried with the following code, where I use <object>.. but it doesn't
      work.. what am I doing wrong?



      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!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" xml:lang="en" lang="en">
      <head>
      <title>Test</title>
      <script type="text/javascript">
      function reload() {
      var el = document.getEle mentById("ifram e");
      el.contentWindo w.location.relo ad();
      }
      var timer = null;
      window.onload = function() {
      timer = setInterval(rel oad, 4000);
      }
      </script>
      </head>
      <body>
      <p>
      Before
      <object id="iframe" type="text/html" data="/content" width="330"
      height="57">
      Blah
      </object>
      After
      </p>
      </body></html>



      --
      Simon Strandgaard


      Comment

      • Randy Webb

        #4
        Re: js with &lt;object&g t; in xhtml strict

        Simon Strandgaard wrote:[color=blue]
        > Grant Wagner wrote:
        >
        >[color=green]
        >>Simon Strandgaard wrote:
        >>
        >>[color=darkred]
        >>>There are no <iframe> tag in xhtml strict, instead I should use
        >>><object>.
        >>>
        >>>If I change <iframe> to <object> then my javascript stops working.
        >>>I am curious to how to use <object> with javascript ?[/color][/color]
        >
        > [snip xhtml]
        >
        >[color=green]
        >>An <object> tag has no -src- attribute: <url:
        >>http://www.w3.org/TR/REC-html40/stru...ts.html#h-13.3 />. Even if it
        >>did, the <object> tag is not a window, so it doesn't have a
        >>-contentWindow-. The <object> tag does have a -data- attribute, you can
        >>probably make use of that fact.[/color]
        >
        >
        >
        > I am curious if its possible to reload an <object>, when its xhtml strict?[/color]

        Did you not read what Grant had to say? An object has a data attribute,
        make use of it. Not that hard to test trying to change its data
        attribute (just setting it back to itself, or, setting it elsewhere and
        then back).
        [color=blue]
        > I have tried with the following code, where I use <object>.. but it doesn't
        > work.. what am I doing wrong?
        >[/color]

        Several things.
        [color=blue]
        >
        > <?xml version="1.0" encoding="ISO-8859-1"?>
        > <!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" xml:lang="en" lang="en">
        > <head>
        > <title>Test</title>
        > <script type="text/javascript">
        > function reload() {
        > var el = document.getEle mentById("ifram e");
        > el.contentWindo w.location.relo ad();[/color]

        objects have no contentWindow, read what Grant said.

        Not a good idea to name your function "reload()" either. It conflicts
        with the native reload() method.

        el.data = "/content";
        might be a place to start.


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

        Comment

        • Simon Strandgaard

          #5
          Re: js with &lt;object&g t; in xhtml strict

          Randy Webb wrote:
          [color=blue]
          > Simon Strandgaard wrote:[color=green]
          >> Grant Wagner wrote:
          >>
          >>[color=darkred]
          >>>Simon Strandgaard wrote:
          >>>
          >>>
          >>>>There are no <iframe> tag in xhtml strict, instead I should use
          >>>><object>.
          >>>>
          >>>>If I change <iframe> to <object> then my javascript stops working.
          >>>>I am curious to how to use <object> with javascript ?[/color]
          >>
          >> [snip xhtml]
          >>
          >>[color=darkred]
          >>>An <object> tag has no -src- attribute: <url:
          >>>http://www.w3.org/TR/REC-html40/stru...ts.html#h-13.3 />. Even if it
          >>>did, the <object> tag is not a window, so it doesn't have a
          >>>-contentWindow-. The <object> tag does have a -data- attribute, you can
          >>>probably make use of that fact.[/color]
          >>
          >>
          >>
          >> I am curious if its possible to reload an <object>, when its xhtml
          >> strict?[/color]
          >
          > Did you not read what Grant had to say? An object has a data attribute,
          > make use of it. Not that hard to test trying to change its data
          > attribute (just setting it back to itself, or, setting it elsewhere and
          > then back).[/color]

          Yes, I read it, but I cannot get (el.data = "someurl") working.
          Im very interested in getting it working.

          [color=blue][color=green]
          >> I have tried with the following code, where I use <object>.. but it
          >> doesn't work.. what am I doing wrong?
          >>[/color]
          >
          > Several things.
          >[color=green]
          >>
          >> <?xml version="1.0" encoding="ISO-8859-1"?>
          >> <!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" xml:lang="en" lang="en">
          >> <head>
          >> <title>Test</title>
          >> <script type="text/javascript">
          >> function reload() {
          >> var el = document.getEle mentById("ifram e");
          >> el.contentWindo w.location.relo ad();[/color]
          >
          > objects have no contentWindow, read what Grant said.[/color]

          Yes, I saw that. I have unsuccessfully tries with data.

          [color=blue]
          > Not a good idea to name your function "reload()" either. It conflicts
          > with the native reload() method.
          >
          > el.data = "/content";
          > might be a place to start.[/color]


          When I assign el.data to the URL, then nothing happens (Firefox +
          Konqueror). Here is my code. I want to reload the <object>, but
          don't know how?


          <?xml version="1.0" encoding="ISO-8859-1"?>
          <!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" xml:lang="en" lang="en">
          <head>
          <title>Test</title>
          <script type="text/javascript">
          function lets_refresh() {
          var el = document.getEle mentById("ifram e");
          el.data = "/content";
          }
          var timer = null;
          window.onload = function() {
          timer = setInterval(let s_refresh, 4000);
          }
          </script>
          </head>
          <body>
          <p>
          Before
          <object id="iframe" type="text/html" data="/content" width="330"
          height="57">
          Blah
          </object>
          After
          </p>
          </body></html>


          Any help is appreciated.

          --
          Simon Strandgaard


          Comment

          • Martin Honnen

            #6
            Re: js with &lt;object&g t; in xhtml strict



            Simon Strandgaard wrote:

            [color=blue]
            > When I assign el.data to the URL, then nothing happens (Firefox +
            > Konqueror). Here is my code. I want to reload the <object>, but
            > don't know how?[/color]

            Use the latest version of Opera then, that can do it. Seriously, if you
            want to embed a HTML document in one document and then be able to script
            it better forget about <object> and use <iframe> instead, iframe is
            rather consistently implemented in older and newer browsers while
            <object> is a mess, in particular when it comes to scripting the loaded
            document. I know that you want XHTML 1.0 strict which has no iframe but
            if you want a solution that works across browsers <object> doesn't help
            and you are better off with <iframe> and XHTML 1.0 transitional.

            --

            Martin Honnen
            http://JavaScript.FAQTs.com/

            Comment

            • Simon Strandgaard

              #7
              Re: js with &lt;object&g t; in xhtml strict

              Martin Honnen wrote:[color=blue]
              > Simon Strandgaard wrote:[color=green]
              >> When I assign el.data to the URL, then nothing happens (Firefox +
              >> Konqueror). Here is my code. I want to reload the <object>, but
              >> don't know how?[/color]
              >
              > Use the latest version of Opera then, that can do it. Seriously, if you
              > want to embed a HTML document in one document and then be able to script
              > it better forget about <object> and use <iframe> instead, iframe is
              > rather consistently implemented in older and newer browsers while
              > <object> is a mess, in particular when it comes to scripting the loaded
              > document. I know that you want XHTML 1.0 strict which has no iframe but
              > if you want a solution that works across browsers <object> doesn't help
              > and you are better off with <iframe> and XHTML 1.0 transitional.[/color]

              Ok, I suspected that this feature still wasn't fully supported yet.
              Thanks for confirming this. If more people can confirm this then please do.

              btw: <iframe> is much easier to search for than <object>.


              if anyone has interest in what I need <object> or <iframe> for,
              then have a look here:


              comments still welcome :-)

              --
              Simon Strandgaard


              Comment

              • Simon Strandgaard

                #8
                Re: js with &lt;object&g t; in xhtml strict

                I have found a way, that works in Firefox.
                (but doesn't work in Konqueror).


                function lets_refresh() {
                var el = document.getEle mentById("ifram e");
                el.contentDocum ent.location.re load();
                }

                <object id="iframe" type="text/html" data="/page.cgi" width="330"
                height="57">
                Blah
                </object>


                Im still interested in a solution that works in Konqueror.
                If anyone happens to know this.. then please let me know.

                --
                Simon Strandgaard

                Comment

                Working...