Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

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

    Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

    Hey there,

    Big-time curiosity issue here...

    Here's the test code (it's not that long)... it's to display a large
    number of image links with captions, ideally pulled in from an
    external file (that part's not here -- spotlighting the problem code):

    --------BEGIN CODE PAGE------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dt d">
    <html>
    <head>
    <title>Test</title>
    <script type="text/javascript">
    function testSpans(sbody ) {
    var sp, i, j, oneRecord;
    sbody = document.getEle mentById(sbody) ;
    for (i = 0; i <= 1; i++) {
    var bkSpan, bkAa, bkAb, bkAex, bkImg, bkTitle,
    bkTypea, bkTypeb, txt, br;
    txt = "Text Text";
    testImg = document.create Element("img");
    testImg.setAttr ibute("src",
    "images/test.gif");
    testA = document.create Element("a");
    testA.setAttrib ute("href",
    "test/url/index.htm");
    testA.appendChi ld(testImg);
    br = document.create Element("br");
    testA.appendChi ld(br);
    testText = document.create TextNode(txt);
    testA.appendChi ld(testText);
    testSpan = document.create Element("span") ;
    testSpan.setAtt ribute("id", i);
    testSpan.style. display = "inline";
    testSpan.style. width = "100px";
    testSpan.append Child(testA);
    sbody.appendChi ld(testSpan);
    }
    }


    function init() {
    testSpans('scoo byDoo');
    }
    </script>
    </head>
    <body onload="init()" >
    <h1>Test</h1>
    <hr />
    <table><tr><t d id="scoobyDoo"> </td></tr></table>
    </body>
    </html>
    --------END CODE PAGE------------

    When it displays, the <span>'s don't line up on the same line like
    they should:

    IMAGE IMAGE
    text text

    Instead, it's as if the first span never ends... the image from the
    second span displays right after the text in the first, like this:

    IMAGE
    text IMAGE
    text

    Using MSIE's "View Partial Source" powertoy, I can see that the
    generated HTML is as follows:

    --------BEGIN GENERATED HTML------------
    <H1>Test</H1>
    <HR>

    <TABLE>
    <TBODY>
    <TR>
    <TD id=scoobyDoo><S PAN id=0 style="DISPLAY: inline; WIDTH: 100px"><A
    href="test/url/index.htm"><IMG height=30 src="images/test.gif"
    width=28><BR>Te xt
    Text</A></SPAN><SPAN id=1 style="DISPLAY: inline; WIDTH: 100px"><A
    href="test/url/index.htm"><IMG height=30 src="images/test.gif"
    width=28><BR>Te xt
    Text</A></SPAN></TD></TR></TBODY></TABLE>
    --------END GENERATED HTML------------

    The problem is that *this is right!* Putting this code in a page
    displays perfectly, but it doesn't when generated by the JavaScript
    shown above.

    Anyone have any ideas? A CSS tag that will help? Another way to
    dynamically create this data? Anything will be appreciated...

    - Akbar

  • Lasse Reichstein Nielsen

    #2
    Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

    Akbar <me@here.com> writes:
    [color=blue]
    > --------BEGIN CODE PAGE------------
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dt d">[/color]

    I see you use a DOCTYPE that puts IE in standards mode.

    [color=blue]
    > When it displays, the <span>'s don't line up on the same line like
    > they should:
    >
    > IMAGE IMAGE
    > text text[/color]

    They shouldn't with the code you generate, not in standards mode.
    [color=blue]
    > <SPAN id=0 style="DISPLAY: inline; WIDTH: 100px">[/color]

    I see a problem right here. The CSS width property should have no
    effect on an inline block.
    [color=blue]
    > The problem is that *this is right!* Putting this code in a page
    > displays perfectly,[/color]

    If by "this code" you mean the above, then notice that you don't have
    a DOCTYPE that puts the browser into standards mode. Add that, and IE
    will show it the same way as when generating it with Javascript.
    [color=blue]
    > Anyone have any ideas? A CSS tag that will help? Another way to
    > dynamically create this data? Anything will be appreciated...[/color]

    Make the blocks display:block and float:left. Then they will line up
    the way you want. Or put them into separate td's.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • DU

      #3
      Re: Script-generated code displaying differntly than the exact samecode displayed staticly... help!?!?!

      Akbar wrote:[color=blue]
      > Hey there,
      >
      > Big-time curiosity issue here...
      >
      > Here's the test code (it's not that long)... it's to display a large
      > number of image links with captions, ideally pulled in from an
      > external file (that part's not here -- spotlighting the problem code):
      >
      > --------BEGIN CODE PAGE------------
      > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      > "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dt d">
      > <html>
      > <head>[/color]

      I usually add these lines into xhtml files:
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="Content-Language" content="en-us" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />

      [color=blue]
      > <title>Test</title>
      > <script type="text/javascript">
      > function testSpans(sbody ) {[/color]



      "In XHTML, the script and style elements are declared as having #PCDATA
      content. As a result, < and & will be treated as the start of markup,
      and entities such as &lt; and &amp; will be recognized as entity
      references by the XML processor to < and & respectively. Wrapping the
      content of the script or style element within a CDATA marked section
      avoids the expansion of these entities."


      So, if you use < or & in your unmarked CDATA function, then it will be
      treated and considered as markup.

      <script type="text/javascript">
      <![CDATA[
      .... unescaped script content ...
      ]]>
      </script>

      is what I suggest here since you use < in your code.
      [color=blue]
      > var sp, i, j, oneRecord;
      > sbody = document.getEle mentById(sbody) ;
      > for (i = 0; i <= 1; i++) {[/color]

      right here, we see the <.
      [color=blue]
      > var bkSpan, bkAa, bkAb, bkAex, bkImg, bkTitle,
      > bkTypea, bkTypeb, txt, br;
      > txt = "Text Text";
      > testImg = document.create Element("img");
      > testImg.setAttr ibute("src",
      > "images/test.gif");[/color]

      Not recommendable. setAttribute should be used only when there is no
      other attribute possible. Here, the simple

      testImg.src = "images/test.gif";

      works.


      [color=blue]
      > testA = document.create Element("a");
      > testA.setAttrib ute("href",
      > "test/url/index.htm");[/color]

      testA.href = "test/url/index.htm";

      [color=blue]
      > testA.appendChi ld(testImg);
      > br = document.create Element("br");
      > testA.appendChi ld(br);
      > testText = document.create TextNode(txt);
      > testA.appendChi ld(testText);[/color]

      or
      testA.appendChi ld(document.cre ateTextNode(txt ));

      [color=blue]
      > testSpan = document.create Element("span") ;
      > testSpan.setAtt ribute("id", i);[/color]

      testSpan.id = i;

      [color=blue]
      > testSpan.style. display = "inline";[/color]

      Per definiion, a span is an inline element. So, there is no need for
      that here.
      [color=blue]
      > testSpan.style. width = "100px";
      > testSpan.append Child(testA);
      > sbody.appendChi ld(testSpan);
      > }
      > }
      >
      >
      > function init() {
      > testSpans('scoo byDoo');
      > }
      > </script>
      > </head>
      > <body onload="init()" >
      > <h1>Test</h1>
      > <hr />
      > <table><tr><t d id="scoobyDoo"> </td></tr></table>
      > </body>
      > </html>
      > --------END CODE PAGE------------
      >
      > When it displays, the <span>'s don't line up on the same line like
      > they should:
      >
      > IMAGE IMAGE
      > text text
      >
      > Instead, it's as if the first span never ends... the image from the
      > second span displays right after the text in the first, like this:
      >
      > IMAGE
      > text IMAGE
      > text
      >
      > Using MSIE's "View Partial Source" powertoy, I can see that the
      > generated HTML is as follows:
      >
      > --------BEGIN GENERATED HTML------------
      > <H1>Test</H1>
      > <HR>
      >
      > <TABLE>
      > <TBODY>
      > <TR>
      > <TD id=scoobyDoo><S PAN id=0 style="DISPLAY: inline; WIDTH: 100px"><A
      > href="test/url/index.htm"><IMG height=30 src="images/test.gif"
      > width=28><BR>Te xt
      > Text</A></SPAN><SPAN id=1 style="DISPLAY: inline; WIDTH: 100px"><A
      > href="test/url/index.htm"><IMG height=30 src="images/test.gif"
      > width=28><BR>Te xt
      > Text</A></SPAN></TD></TR></TBODY></TABLE>
      > --------END GENERATED HTML------------
      >
      > The problem is that *this is right!* Putting this code in a page
      > displays perfectly, but it doesn't when generated by the JavaScript
      > shown above.
      >
      > Anyone have any ideas? A CSS tag that will help? Another way to
      > dynamically create this data? Anything will be appreciated...
      >
      > - Akbar
      >[/color]

      2 other suggestions:
      - write a short but meaningful subject line in your post. Just
      "Script-generated code displaying differntly" was sufficient
      - try to upload your code, page somewhere and then just give the url;
      that's always better and so much more convenient as the code can be
      tested with various softwares (validations, verifying http headers, link
      validators, accessibility validators,etc. .)

      DU
      --
      Javascript and Browser bugs:

      - Resources, help and tips for Netscape 7.x users and Composer
      - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


      Comment

      • Akbar

        #4
        Re: Script-generated code displaying differntly

        DU,

        Lots of great info! Thanks! Some issues tho...

        On Sun, 07 Sep 2003 15:11:56 -0400, DU <drunclear@hotR EMOVEmail.com>
        wrote:
        [color=blue]
        >So, if you use < or & in your unmarked CDATA function, then it will be
        >treated and considered as markup.
        >
        ><script type="text/javascript">
        ><![CDATA[
        >... unescaped script content ...
        >]]>
        ></script>
        >
        >is what I suggest here since you use < in your code.
        >[color=green]
        >> var sp, i, j, oneRecord;
        >> sbody = document.getEle mentById(sbody) ;
        >> for (i = 0; i <= 1; i++) {[/color]
        >
        >right here, we see the <.[/color]

        Tried this, now IE throws Syntax Errors. :( (In Opera7, it doesn;t
        do anything at all... hmmmm. Neither does another page that works
        fine.. hmmmmmmm.)
        [color=blue][color=green]
        >> testImg.setAttr ibute("src", "images/test.gif");[/color]
        >
        >Not recommendable. setAttribute should be used only when there is no
        >other attribute possible. Here, the simple
        >
        > testImg.src = "images/test.gif";
        >
        >works.[/color]

        Thanks! Me == newb. Got most of this from an O'Reilly cookbook.
        Learning by example...
        [color=blue][color=green]
        >> testSpan.style. display = "inline";[/color]
        >
        >Per definiion, a span is an inline element. So, there is no need for
        >that here.[/color]

        This was me trying just about anything to see what might work to fix
        it...
        [color=blue]
        >2 other suggestions:
        >- write a short but meaningful subject line in your post. Just
        >"Script-generated code displaying differntly" was sufficient[/color]

        'kay.
        [color=blue]
        >- try to upload your code, page somewhere and then just give the url;
        >that's always better and so much more convenient as the code can be
        >tested with various softwares (validations, verifying http headers, link
        >validators, accessibility validators,etc. .)[/color]

        'kay

        Thanks again!

        - Akbar

        Comment

        • Akbar

          #5
          Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

          On 07 Sep 2003 21:12:04 +0200, Lasse Reichstein Nielsen
          <lrn@hotpop.com > wrote:
          [color=blue]
          >Akbar <me@here.com> writes:
          >[color=green]
          >> --------BEGIN CODE PAGE------------
          >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          >> "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dt d">[/color]
          >
          >I see you use a DOCTYPE that puts IE in standards mode.[/color]

          Actaully, I'm just using the HomeSite default new-page template. :)
          [color=blue][color=green]
          >> When it displays, the <span>'s don't line up on the same line like
          >> they should:
          >>
          >> IMAGE IMAGE
          >> text text[/color]
          >
          >They shouldn't with the code you generate, not in standards mode.[/color]

          Hm. They do when the code is input static-ly versus dynamically. Go
          figure...
          [color=blue][color=green]
          >> <SPAN id=0 style="DISPLAY: inline; WIDTH: 100px">[/color]
          >
          >I see a problem right here. The CSS width property should have no
          >effect on an inline block.[/color]

          Without the WIDTH property, the text below the image wouldn't wrap to
          stay below the image.
          [color=blue][color=green]
          >> The problem is that *this is right!* Putting this code in a page
          >> displays perfectly,[/color]
          >
          >If by "this code" you mean the above, then notice that you don't have
          >a DOCTYPE that puts the browser into standards mode.[/color]

          But the first this you said above was that I "use a DOCTYPE that puts
          IE in standards mode." Now you say I "*don't* have a DOCTYPE that puts
          the browser into standards mode." (Emphasis mine) Which is it? :(
          [color=blue]
          >Add that, and IE
          >will show it the same way as when generating it with Javascript.[/color]

          What DOCTYPE would you recommend?
          [color=blue]
          >Make the blocks display:block and float:left. Then they will line up
          >the way you want. Or put them into separate td's.[/color]

          Nope. Tried this and they all displayed in a vert line down the left
          side. Wanted them to appear like words on a page, each span walking
          from left to right across the page then wrapping at the edge of the
          page.

          Thanks for you comments!

          - Akbar

          Comment

          • Lasse Reichstein Nielsen

            #6
            Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

            Akbar <me@here.com> writes:
            [color=blue][color=green][color=darkred]
            > >> <SPAN id=0 style="DISPLAY: inline; WIDTH: 100px">[/color]
            > >
            > >I see a problem right here. The CSS width property should have no
            > >effect on an inline block.[/color]
            >
            > Without the WIDTH property, the text below the image wouldn't wrap to
            > stay below the image.[/color]

            With a width property, in standards mode, it won't either, since the
            width property of inline elements are ignored.
            [color=blue][color=green][color=darkred]
            > >> The problem is that *this is right!* Putting this code in a page
            > >> displays perfectly,[/color]
            > >
            > >If by "this code" you mean the above, then notice that you don't have
            > >a DOCTYPE that puts the browser into standards mode.[/color]
            >
            > But the first this you said above was that I "use a DOCTYPE that puts
            > IE in standards mode." Now you say I "*don't* have a DOCTYPE that puts
            > the browser into standards mode." (Emphasis mine) Which is it? :([/color]

            Do you put the code into the same page, or into a page of its own?

            If I take the generated code that you showed, and put it into a page
            of its own, then it displays the way you want. Because the generated
            code doesn't have a DOCTYPE, *taht* page is displayed in quirks mode.

            If I then copy the DOCTYPE from the original page and add it to the
            top of the generated code, then the generated code is shown according
            to standards. And it displays the way you don't want it to, but that
            the standards mandate.
            [color=blue]
            > What DOCTYPE would you recommend?[/color]

            Any will do, as long as the HTML/XHTML actually follows the DOCTYPE.
            To enforce standards mode, you will have to pick a DOCTYPE that triggers
            standards mode. I prefer HTML 4.01 (strict) or XHTML 1.1, but it's not
            that important, as long as you add a correct URL.

            The generated code has tag names in capital letters, so it's not XHTML.
            Then I would use:
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/REC-html401/strict.dtd">

            This page shows the DOCTYPE effects in Opera, which is similar to IE and
            Mozilla: <URL:http://www.opera.com/docs/specs/doctype/>

            [float:left][color=blue]
            > Nope. Tried this and they all displayed in a vert line down the left
            > side. Wanted them to appear like words on a page, each span walking
            > from left to right across the page then wrapping at the edge of the
            > page.[/color]

            That is probably becaue you have wrapped it in a table. A table with one
            cell is rarely necessary.

            Try looking at this page:
            ---
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/REC-html401/strict.dtd">
            <HTML>
            <HEAD><TITLE>Te st page</TITLE></HEAD>
            <BODY>
            <DIV style="border:1 px solid green;width:350 px;height:300px ;">
            <DIV style="width:10 0px;float:left; ">
            <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicA.png"><BR>
            Some Text</A></DIV>
            <DIV style="width:10 0px;float:left; ">
            <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicB.png"><BR>
            Some more text</A></DIV>
            <DIV style="width:10 0px;float:left; ">
            <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicA.png"><BR>
            small text</A></DIV>
            <DIV style="width:10 0px;float:left; ">
            <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicB.png"><BR>
            Text that goes on for miles and miles</A></DIV>
            </DIV>
            </BODY>
            </HTML>
            ---
            The divs (no need to use spans, floats are automatically made block
            elements) line up fine, and wrap to the next line when there isn't room
            enough.

            /L
            --
            Lasse Reichstein Nielsen - lrn@hotpop.com
            Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
            'Faith without judgement merely degrades the spirit divine.'

            Comment

            • Akbar

              #7
              Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

              Replace the first DIVs text wth the fourth's and this code breaks. See
              here -> http://www.straffin.com/test/divtest.html

              Thank you for your help... I really want to do this right (so it
              *works* and is *standard*), but I'm just not seeing how...

              - Akbar

              On 10 Sep 2003 11:25:50 +0200, Lasse Reichstein Nielsen
              <lrn@hotpop.com > wrote:
              [color=blue]
              > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
              > "http://www.w3.org/TR/REC-html401/strict.dtd">
              > <HTML>
              > <HEAD><TITLE>Te st page</TITLE></HEAD>
              > <BODY>
              > <DIV style="border:1 px solid green;width:350 px;height:300px ;">
              > <DIV style="width:10 0px;float:left; ">
              > <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicA.png"><BR>
              > Some Text</A></DIV>
              > <DIV style="width:10 0px;float:left; ">
              > <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicB.png"><BR>
              > Some more text</A></DIV>
              > <DIV style="width:10 0px;float:left; ">
              > <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicA.png"><BR>
              > small text</A></DIV>
              > <DIV style="width:10 0px;float:left; ">
              > <A HREF=""><IMG SRC="http://www.infimum.dk/privat/PicB.png"><BR>
              > Text that goes on for miles and miles</A></DIV>
              > </DIV>
              > </BODY>
              > </HTML>[/color]

              Comment

              • Lasse Reichstein Nielsen

                #8
                Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

                Akbar <me@here.com> writes:
                [color=blue]
                > Replace the first DIVs text wth the fourth's and this code breaks. See
                > here -> http://www.straffin.com/test/divtest.html[/color]

                Ah, well noticed. To avoid that, you must make every box the same
                height, by setting the height property of the divs.

                /L
                --
                Lasse Reichstein Nielsen - lrn@hotpop.com
                Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
                'Faith without judgement merely degrades the spirit divine.'

                Comment

                • Akbar

                  #9
                  Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

                  On 11 Sep 2003 04:36:27 +0200, Lasse Reichstein Nielsen
                  <lrn@hotpop.com > wrote:
                  [color=blue]
                  >Akbar <me@here.com> writes:
                  >[color=green]
                  >> Replace the first DIVs text wth the fourth's and this code breaks. See
                  >> here -> http://www.straffin.com/test/divtest.html[/color]
                  >
                  >Ah, well noticed. To avoid that, you must make every box the same
                  >height, by setting the height property of the divs.[/color]

                  And I can do that, but when I put this logic into my JavaScript, it
                  does the same thing the SPANs were doing.

                  This script --> http://www.straffin.com/test/dynamic.html
                  generates this HTML --> http://www.straffin.com/test/static.html
                  but they don't work/look the same. :(

                  I believe that DU had something whet he mentioned using CDATA, but I
                  cannot get that to work at all... it just gives syntax errors. There's
                  enough code that I could pull it out into an external file, but am not
                  sure how to do so.

                  Any pointers on the CDATA or external file stuff? :)

                  - Akbar

                  Comment

                  • DU

                    #10
                    Re: Script-generated code displaying differntly than the exact samecode displayed staticly... help!?!?!

                    Akbar wrote:

                    [color=blue]
                    >
                    > This script --> http://www.straffin.com/test/dynamic.html
                    > generates this HTML --> http://www.straffin.com/test/static.html
                    > but they don't work/look the same. :(
                    >[/color]

                    You have to first establish what you want here: an HTML 4.01 strict DTD
                    or an XHMTL 1 transitional DTD. Because I gave you numerous advices
                    based on the DTD you first chose. If you later remove that DTD, then
                    such advices if not removed will likely cause validation errors and
                    script errors.
                    [color=blue]
                    > I believe that DU had something whet he mentioned using CDATA, but I
                    > cannot get that to work at all... it just gives syntax errors. There's
                    > enough code that I could pull it out into an external file,[/color]

                    You do not need to create an external file. Creating an external .js
                    file (regardless of DTD) is recommendable when the .js file is likely to
                    be used again for other files; cached files save http connection trips
                    to the server.

                    but am not[color=blue]
                    > sure how to do so.[/color]

                    Don't worry, I have done this before and I still have an entire working
                    example in a file.
                    [color=blue]
                    >
                    > Any pointers on the CDATA or external file stuff? :)
                    >
                    > - Akbar
                    >[/color]

                    This code works in Mozilla 1.5b, NS 7.1, Opera 7.20 and MSIE 6 for
                    Windows. I corrected a lot of misses in your code, removed unnecessary
                    variables, tuned their declarations and assignments and optimized the
                    code at several places. The color borders, commented out, are only there
                    for some visual feedback of the layout.
                    If you want all your <div>s to be on an horizontal line in MSIE 6 for
                    Windows as well, then you'll need to make some changes to the code.
                    Creating <div>s and adding a <br> to anchor objects certainly does NOT
                    seem to be necessary nor needed: I think it's only there to have the
                    text right under the image and links all lined up horizontally.

                    ----------------
                    <!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-us">

                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                    <meta http-equiv="Content-Language" content="en-us" />
                    <meta http-equiv="Content-Style-Type" content="text/css" />
                    <meta http-equiv="Content-Script-Type" content="text/javascript" />

                    <title>Creati ng dynamically an html file</title>

                    <style type="text/css">
                    p#validation img {width:88px; height:31px; margin:0 0.5em;}
                    </style>

                    <script type="text/javascript">
                    // <![CDATA[
                    function testDivs(sbody)
                    {
                    for (var iterator = 0; iterator < 7; iterator++)
                    {
                    var DOMobjImg = document.create Element("img");
                    DOMobjImg.src =
                    "http://www10.brinkster .com/doctorunclear/GRAPHICS/GIF/Wavey.gif";
                    DOMobjImg.width = "25";
                    DOMobjImg.heigh t = "29";
                    DOMobjImg.alt = ":)";
                    // DOMobjImg.alt = "Relevant meaningful alternate text";
                    var DOMobjA = document.create Element("a");
                    DOMobjA.href = "http://www.yahoo.com/";
                    DOMobjA.title = "Yahoo.com" ;
                    DOMobjA.appendC hild(DOMobjImg) ;
                    var br = document.create Element("br");
                    DOMobjA.appendC hild(br);

                    DOMobjA.style.m argin = "0 6px";
                    //DOMobjA.style.b order = "1px dashed green";
                    DOMobjA.appendC hild(document.c reateTextNode(" Anchor" + iterator));
                    var DOMobjDiv = document.create Element("div");
                    /* DOMobjDiv.id = iterator; Why give such div an id? */
                    DOMobjDiv.style .cssFloat = "left";
                    DOMobjDiv.style .width = "100px";
                    // DOMobjDiv.style .border = "1px dotted red";
                    DOMobjDiv.appen dChild(DOMobjA) ;
                    document.getEle mentById(sbody) .appendChild(DO MobjDiv);
                    };
                    var strTest = " < & ";
                    }
                    // ]]>
                    </script>

                    </head>
                    <body onload="testDiv s('scoobyDoo'); ">
                    <h1>Test</h1>
                    <hr />
                    <table border="2" frame="box" width="724" style="margin:0 auto;"><tr><td
                    id="scoobyDoo"> </td></tr></table>
                    <p id="validation" ><a href="http://validator.w3.or g/check/referer"><img
                    src="http://www.w3.org/Icons/valid-xhtml10.png" title="Verify this
                    page's markup syntax" alt="Valid XHTML 1.0!" /></a> <a
                    href="http://jigsaw.w3.org/css-validator/check/referer"><img
                    src="http://jigsaw.w3.org/css-validator/images/vcss" title="Verify this
                    page's CSS code" alt="CSS compliant" /></a></p>

                    </body>
                    </html>

                    DU
                    --
                    Javascript and Browser bugs:

                    - Resources, help and tips for Netscape 7.x users and Composer
                    - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


                    Comment

                    • Akbar

                      #11
                      Re: Script-generated code displaying differntly than the exact same code displayed staticly... help!?!?!

                      On Thu, 11 Sep 2003 00:37:06 -0400, DU <drunclear@hotR EMOVEmail.com>
                      wrote:
                      [color=blue]
                      >This code works in Mozilla 1.5b, NS 7.1, Opera 7.20 and MSIE 6 for
                      >Windows. I corrected a lot of misses in your code, removed unnecessary
                      >variables, tuned their declarations and assignments and optimized the
                      >code at several places. The color borders, commented out, are only there
                      >for some visual feedback of the layout.[/color]

                      Thanks very much... this is great!
                      [color=blue]
                      >If you want all your <div>s to be on an horizontal line in MSIE 6 for
                      >Windows as well, then you'll need to make some changes to the code.[/color]

                      For example? (Whether I like it or not, IE will be the target browser
                      and needs to work there above all.)
                      [color=blue]
                      >Creating <div>s and adding a <br> to anchor objects certainly does NOT
                      >seem to be necessary nor needed: I think it's only there to have the
                      >text right under the image and links all lined up horizontally.[/color]

                      If I get rid of the <br> and add a space between the img and the text,
                      it works. See http://www.straffin.com/test/DUdyn2.html for my sample
                      (and the code for my next questions! <grin />)

                      ---snip---[color=blue]
                      >/* DOMobjDiv.id = iterator; Why give such div an id? */[/color]
                      ---snip---

                      I had been trying something else and they got left behind.

                      I added the next step of the code to th esample above, which works
                      okay, but I'm not pleased with my "alternate" use of the ALT tag. Any
                      suggestions for a different place to store "variables" in HTML? Also,
                      the placement of the validation imgs are acting funny... thoughts?

                      - Akbar

                      Comment

                      • Akbar

                        #12
                        ATTN DU: Horiz &lt;div&gt;' s in IE6? How?

                        On Thu, 11 Sep 2003 10:22:09 GMT, Akbar <me@here.com> wrote:
                        [color=blue]
                        >On Thu, 11 Sep 2003 00:37:06 -0400, DU <drunclear@hotR EMOVEmail.com>
                        >wrote:
                        >[color=green]
                        >>If you want all your <div>s to be on an horizontal line in MSIE 6 for
                        >>Windows as well, then you'll need to make some changes to the code.[/color]
                        >
                        >For example? (Whether I like it or not, IE will be the target browser
                        >and needs to work there above all.)[/color]

                        To paraphrase Oliver -- Please sir, may I have some more (info)? :)

                        - Akbar

                        Comment

                        • Akbar

                          #13
                          ATTN DU: Horiz &lt;div&gt;' s in IE6? How? (take 2)

                          On Fri, 12 Sep 2003 04:49:19 GMT, Akbar <me@here.com> wrote:
                          [color=blue]
                          >On Thu, 11 Sep 2003 10:22:09 GMT, Akbar <me@here.com> wrote:
                          >[color=green]
                          >>On Thu, 11 Sep 2003 00:37:06 -0400, DU <drunclear@hotR EMOVEmail.com>
                          >>wrote:
                          >>[color=darkred]
                          >>>If you want all your <div>s to be on an horizontal line in MSIE 6 for
                          >>>Windows as well, then you'll need to make some changes to the code.[/color]
                          >>
                          >>For example? (Whether I like it or not, IE will be the target browser
                          >>and needs to work there above all.)[/color]
                          >
                          >To paraphrase Oliver -- Please sir, may I have some more (info)? :)[/color]

                          Pretty please? I'd really, really like to know what "changes" you were
                          aluding to when you said that "If you want all your <div>s to be on an
                          horizontal line in MSIE 6 for Windows as well, then you'll need to
                          make some changes to the code."

                          - Akbar

                          Comment

                          • Akbar

                            #14
                            DU DU DU!!! Will you please finish your thoughts on horiz &lt;div&gt;' s in IE6? PLEEEEEASE!?!?! ?

                            On Sat, 13 Sep 2003 21:56:23 GMT, Akbar <me@here.com> wrote:
                            [color=blue]
                            >On Fri, 12 Sep 2003 04:49:19 GMT, Akbar <me@here.com> wrote:
                            >[color=green]
                            >>On Thu, 11 Sep 2003 10:22:09 GMT, Akbar <me@here.com> wrote:
                            >>[color=darkred]
                            >>>On Thu, 11 Sep 2003 00:37:06 -0400, DU <drunclear@hotR EMOVEmail.com>
                            >>>wrote:
                            >>>
                            >>>>If you want all your <div>s to be on an horizontal line in MSIE 6 for
                            >>>>Windows as well, then you'll need to make some changes to the code.
                            >>>
                            >>>For example? (Whether I like it or not, IE will be the target browser
                            >>>and needs to work there above all.)[/color]
                            >>
                            >>To paraphrase Oliver -- Please sir, may I have some more (info)? :)[/color]
                            >
                            >Pretty please? I'd really, really like to know what "changes" you were
                            >aluding to when you said that "If you want all your <div>s to be on an
                            >horizontal line in MSIE 6 for Windows as well, then you'll need to
                            >make some changes to the code."
                            >
                            >- Akbar[/color]

                            PLEEEEEASE!?!?!

                            - Akbar

                            Comment

                            • JimMenees

                              #15
                              Re: DU DU DU!!! Will you please finish your thoughts on horiz &lt;div&gt;' s in IE6? PLEEEEEASE!?!?! ?

                              Use css:
                              <div style="display: inline"

                              or in your style sheet
                              <style type='text/css'>
                              ..mydivclassnam e {display:inline }
                              </style
                              <div class='mydivcla ssname' ......


                              Comment

                              Working...