Write on <OBJECT type="text/html"> ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arash Dejkam

    Write on <OBJECT type="text/html"> ?

    Hi All,

    Is it possible to write on an <OBJECT type="text/html"> using
    document.write( ) from within the html containing that tag the way we write
    on a popup window? I couldn't do that after a lot of try.

    Thanks in advance.


  • Will Gittoes

    #2
    Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

    Arash Dejkam wrote:[color=blue]
    > Hi All,
    >
    > Is it possible to write on an <OBJECT type="text/html"> using
    > document.write( ) from within the html containing that tag the way we write
    > on a popup window? I couldn't do that after a lot of try.
    >
    > Thanks in advance.
    >
    >[/color]

    Remember, you can use single quotes as well.

    document.write( "<OBJECT type='text/html'>")
    | |
    Single quotes----------------+---------+

    Don't cross-post, please.

    Comment

    • Arash Dejkam

      #3
      Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?


      "Will Gittoes" <AskMeForIt@NoS pam.org> wrote in message
      news:1090227435 .299047@radsrv1 .tranzpeer.net. ..[color=blue]
      > Arash Dejkam wrote:[color=green]
      > > Hi All,
      > >
      > > Is it possible to write on an <OBJECT type="text/html"> using
      > > document.write( ) from within the html containing that tag the way we[/color][/color]
      write[color=blue][color=green]
      > > on a popup window? I couldn't do that after a lot of try.
      > >
      > > Thanks in advance.
      > >
      > >[/color]
      >
      > Remember, you can use single quotes as well.
      >
      > document.write( "<OBJECT type='text/html'>")
      > | |
      > Single quotes----------------+---------+
      >
      > Don't cross-post, please.[/color]

      You didn't get the point.
      I don't want to write on my html but on the object frame itself, something
      like this:

      <object id="foo" type="text/html" />
      <script>
      foo.document.wr ite("Hello World!");
      </script>


      Comment

      • Rob Collyer

        #4
        Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

        > Arash Dejkam wrote:[color=blue][color=green]
        >> Hi All,
        >>
        >> Is it possible to write on an <OBJECT type="text/html"> using
        >> document.write( ) from within the html containing that tag the way we
        >> write on a popup window? I couldn't do that after a lot of try.
        >>
        >> Thanks in advance.[/color][/color]

        Yes it is possible to output any type of mark-up at run-time using document.write.

        --
        Robert Collyer
        Find haunted houses near you or search for real haunted places. FrightFind.com connects you with all things scary. Find haunts now.

        Free Web Design and Development Help, Discussions, tips and Critique!
        ASP, VB, .NET, SQL, CSS, HTML, Javascript, Flash, XML, SEO !

        Comment

        • SpaceGirl

          #5
          Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

          Will Gittoes wrote:
          [color=blue]
          > Arash Dejkam wrote:
          >[color=green]
          >> Hi All,
          >>
          >> Is it possible to write on an <OBJECT type="text/html"> using
          >> document.write( ) from within the html containing that tag the way we
          >> write
          >> on a popup window? I couldn't do that after a lot of try.
          >>
          >> Thanks in advance.
          >>
          >>[/color]
          >
          > Remember, you can use single quotes as well.
          >
          > document.write( "<OBJECT type='text/html'>")
          > | |
          > Single quotes----------------+---------+
          >
          > Don't cross-post, please.[/color]

          or

          document.write( "<OBJECT type=\"text/html\">")
          | |
          forces the character following to be ignored



          --


          x theSpaceGirl (miranda)

          # lead designer @ http://www.dhnewmedia.com #
          # remove NO SPAM to email, or use form on website #

          Comment

          • Rob Collyer

            #6
            Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

            "Arash Dejkam" <dejkam@softhom e.net> wrote in
            news:2m1hqiFhni iiU1@uni-berlin.de:
            [color=blue]
            >
            > "Will Gittoes" <AskMeForIt@NoS pam.org> wrote in message
            > news:1090227435 .299047@radsrv1 .tranzpeer.net. ..[color=green]
            >> Arash Dejkam wrote:[color=darkred]
            >> > Hi All,
            >> >
            >> > Is it possible to write on an <OBJECT type="text/html"> using
            >> > document.write( ) from within the html containing that tag the way
            >> > we[/color][/color]
            > write[color=green][color=darkred]
            >> > on a popup window? I couldn't do that after a lot of try.
            >> >
            >> > Thanks in advance.
            >> >
            >> >[/color]
            >>
            >> Remember, you can use single quotes as well.
            >>
            >> document.write( "<OBJECT type='text/html'>")
            >> | |
            >> Single quotes----------------+---------+
            >>
            >> Don't cross-post, please.[/color]
            >
            > You didn't get the point.
            > I don't want to write on my html but on the object frame itself,
            > something like this:
            >
            > <object id="foo" type="text/html" />
            > <script>
            > foo.document.wr ite("Hello World!");
            > </script>
            >
            >
            >[/color]

            What exactly are you trying to achieve?

            There must be a better way, than the way you are approching this.

            --
            Robert Collyer
            Find haunted houses near you or search for real haunted places. FrightFind.com connects you with all things scary. Find haunts now.

            Free Web Design and Development Help, Discussions, tips and Critique!
            ASP, VB, .NET, SQL, CSS, HTML, Javascript, Flash, XML, SEO !

            Comment

            • Martin Honnen

              #7
              Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?



              Arash Dejkam wrote:

              [color=blue]
              > Is it possible to write on an <OBJECT type="text/html"> using
              > document.write( ) from within the html containing that tag the way we write
              > on a popup window? I couldn't do that after a lot of try.[/color]

              You can do in Netscape 7, Mozilla and Opera 7 using the contentDocument
              at least but it doesn't work in IE(5/6):

              <html lang="en">
              <head>
              <title>the document object of an embedded object</title>
              <script type="text/javascript">
              function initObject () {
              var object, objDoc;
              if (document.getEl ementById && (object =
              document.getEle mentById('anObj ect'))) {
              if (object.content Document) {
              objDoc = object.contentD ocument;
              }
              else if (object.content Window) {
              objDoc = object.contentW indow.document;
              }
              if (objDoc) {
              initDoc(objDoc) ;
              }
              }
              }

              function initDoc (doc) {
              doc.open();
              doc.write([
              '<html><head><t itle>document.w ritten content<\/title><\/head>',
              '<body><p>Kibol ogy for all.<\/p><\/body><\/html>'
              ].join('\r\n'));
              doc.close();
              }

              window.onload = function (evt) {
              initObject();
              };
              </script>
              </head>
              <body>
              <p>
              Here is the object:
              <object type="text/html" id="anObject"
              width="200" height="200"
              data="about:bla nk"></object>
              </p>
              </body>
              </html>

              Can anyone report back whether the above writes to the object document
              with Safari or Konqueror?

              contentDocument is specified in the W3C DOM Level 2 HTML, see

              so newer browser like Safari or Konqueror should support it.

              But if you want to embed text/html and access its document then simply
              go for
              <iframe name="iframeNam e" ...></iframe>
              and then you should have no trouble in browsers since IE4, Opera 6,
              Netscape 6 etc accessing
              window.frames.i frameName.docum ent
              with script.

              --

              Martin Honnen


              Comment

              • Arash Dejkam

                #8
                Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

                Thanks Martin!

                bad news it doesn't work in IE!, by the way, I tested your code in Opera
                7.01 Build 2651 and it DIDN'T work! but worked in mozilla. I can't use
                IFRAME because my page should be XHTML1.0 Strict.

                Arash

                "Martin Honnen" <mahotrash@yaho o.de> wrote in message
                news:40fba342$1 @olaf.komtel.ne t...[color=blue]
                >
                >
                > Arash Dejkam wrote:
                >
                >[color=green]
                > > Is it possible to write on an <OBJECT type="text/html"> using
                > > document.write( ) from within the html containing that tag the way we[/color][/color]
                write[color=blue][color=green]
                > > on a popup window? I couldn't do that after a lot of try.[/color]
                >
                > You can do in Netscape 7, Mozilla and Opera 7 using the contentDocument
                > at least but it doesn't work in IE(5/6):
                >
                > <html lang="en">
                > <head>
                > <title>the document object of an embedded object</title>
                > <script type="text/javascript">
                > function initObject () {
                > var object, objDoc;
                > if (document.getEl ementById && (object =
                > document.getEle mentById('anObj ect'))) {
                > if (object.content Document) {
                > objDoc = object.contentD ocument;
                > }
                > else if (object.content Window) {
                > objDoc = object.contentW indow.document;
                > }
                > if (objDoc) {
                > initDoc(objDoc) ;
                > }
                > }
                > }
                >
                > function initDoc (doc) {
                > doc.open();
                > doc.write([
                > '<html><head><t itle>document.w ritten content<\/title><\/head>',
                > '<body><p>Kibol ogy for all.<\/p><\/body><\/html>'
                > ].join('\r\n'));
                > doc.close();
                > }
                >
                > window.onload = function (evt) {
                > initObject();
                > };
                > </script>
                > </head>
                > <body>
                > <p>
                > Here is the object:
                > <object type="text/html" id="anObject"
                > width="200" height="200"
                > data="about:bla nk"></object>
                > </p>
                > </body>
                > </html>
                >
                > Can anyone report back whether the above writes to the object document
                > with Safari or Konqueror?
                >
                > contentDocument is specified in the W3C DOM Level 2 HTML, see
                > http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-38538621
                > so newer browser like Safari or Konqueror should support it.
                >
                > But if you want to embed text/html and access its document then simply
                > go for
                > <iframe name="iframeNam e" ...></iframe>
                > and then you should have no trouble in browsers since IE4, Opera 6,
                > Netscape 6 etc accessing
                > window.frames.i frameName.docum ent
                > with script.
                >
                > --
                >
                > Martin Honnen
                > http://JavaScript.FAQTs.com/
                >[/color]


                Comment

                • Martin Honnen

                  #9
                  Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?



                  Arash Dejkam wrote:

                  [color=blue]
                  > bad news it doesn't work in IE!, by the way, I tested your code in Opera
                  > 7.01 Build 2651 and it DIDN'T work![/color]

                  One reason more to go for the iframe. Sorry for not being more specific
                  about Opera, I had only tested with Opera 7.50 on Windows and as I don't
                  use <object> myself to render text/html I had no knowledge about details
                  of Opera support for contentDocument .

                  [color=blue]
                  > but worked in mozilla. I can't use
                  > IFRAME because my page should be XHTML1.0 Strict.[/color]

                  It is your decision, if that document type is important to you then you
                  can't use iframe but currently with the browsers around if you are
                  interested in consistent and reliable use and scripting then iframe is
                  much better than object.

                  --

                  Martin Honnen


                  Comment

                  • DU

                    #10
                    Re: Write on &lt;OBJECT type=&quot;text/html&quot;&gt; ?

                    Martin Honnen wrote:[color=blue]
                    >
                    >
                    > Arash Dejkam wrote:
                    >
                    >[color=green]
                    >> Is it possible to write on an <OBJECT type="text/html"> using
                    >> document.write( ) from within the html containing that tag the way we
                    >> write
                    >> on a popup window? I couldn't do that after a lot of try.[/color]
                    >
                    >
                    > You can do in Netscape 7, Mozilla and Opera 7 using the contentDocument
                    > at least but it doesn't work in IE(5/6):
                    >
                    > <html lang="en">
                    > <head>
                    > <title>the document object of an embedded object</title>
                    > <script type="text/javascript">
                    > function initObject () {
                    > var object, objDoc;
                    > if (document.getEl ementById && (object =
                    > document.getEle mentById('anObj ect'))) {
                    > if (object.content Document) {
                    > objDoc = object.contentD ocument;
                    > }
                    > else if (object.content Window) {[/color]


                    contentWindow can not apply to HTML object element
                    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


                    [color=blue]
                    > objDoc = object.contentW indow.document;
                    > }[/color]

                    [color=blue]
                    > if (objDoc) {
                    > initDoc(objDoc) ;
                    > }
                    > }
                    > }
                    >
                    > function initDoc (doc) {
                    > doc.open();
                    > doc.write([
                    > '<html><head><t itle>document.w ritten content<\/title><\/head>',
                    > '<body><p>Kibol ogy for all.<\/p><\/body><\/html>'
                    > ].join('\r\n'));
                    > doc.close();[/color]


                    or

                    var objParg = doc.createEleme nt("p");
                    objParg.appendC hild(doc.create TextNode("Kibol ogy for all."));
                    doc.body.append Child(objParg);
                    since blank document have a body node.
                    [color=blue]
                    > }
                    >
                    > window.onload = function (evt) {
                    > initObject();[/color]

                    Isn't that asking for trouble? Like asynchronous onload events for
                    window and document body?
                    [color=blue]
                    > };[/color]


                    DU
                    --
                    The site said to use Internet Explorer 5 or better... so I switched to
                    Mozilla 1.7.3 :)

                    Comment

                    Working...