Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with dynamic style sheet (VB 6)

    I am dynamically creating an HTML file. I mainly have a shell and set the innerHTML of some DIVs to what I want. I then want to set a stylesheet for my document.

    I try oHTMLDom.createStyleSheet(...) where oHTMLDom is a MSHTML::HTMLDocument object.

    This seems to create and add the stylesheet to the document (I checked it by checking the styleSheets collection and also outputting oHTMLDom.getElementsByTagName("HEAD").item(0).oute rhtml and it appears to now contain a <LINK href...

    However none of the styles apply to the document.

    I am 100% sure my stylesheet is correct

    When I applied styles to individual tags (rather than document level), it seemed to apply fine.

    Anyone have any idea why this isn't working?

    I appreciate any and all help.

    Thank you,
    Chad

    P.S. Please don't respond by suggesting me to change my entire fundamental way of doing this (ie, "use asp", "why are you starting with a shell"). I would like to get it working this way or at least know why it cannot work this way.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Problem with dynamic style sheet (VB 6)

    Could it be tables? Try adding TD prefaced definitions, e.g.,

    p, td p {etc.}

    Or maybe this is only necessary in Netscape. I forget.

  3. #3
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with dynamic style sheet (VB 6)

    I checked on that. Ran my code through a HTML checker and made sure all my tags were properly closing, etc.

    Any other ideas?

    Has anyone attempted to do what I am doing in VB?

    Thanks,
    Chad

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Problem with dynamic style sheet (VB 6)

    This seems to be an important clue:

    > When I applied styles to individual tags (rather than document level), it seemed to apply fine.

    Can you elaborate? Did you add a CLASS="selector" tag and that worked, or did you manually code the style with a STYLE="etc." tag? If the first method works, it would confirm that the LINK tag is working correctly. The second method really doesn't tell us anything.

  5. #5
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with dynamic style sheet (VB 6)

    Unfortunately, I did it the second way. My HTML is generated with the CLASS tags in it already.

    Chad

  6. #6
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with dynamic style sheet (VB 6)

    Just another note. I took the code of the generated file (oHTMLDom.getElementsByTagName("HTML").item(0).out erhtml)

    and pasted it into a static html file. It rendered beautifully.

    I don't understand why it isn't working dynamically though.

    Chad

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Problem with dynamic style sheet (VB 6)

    > I took the code of the generated file (oHTMLDom.getElementsByTagName("HTML").item(0).out erhtml) and
    > pasted it into a static html file. It rendered beautifully.

    Does that mean the entire document? I'm not all that familiar with DOM, but if that returns the entire contents of the HTML tag, inclusive of the tags, that's what I thought you had before.

    If you are writing to a browser window rather than first creating and then loading a document, it may well be that the style sheet will not load, or maybe you simply have to create the style sheet first. You could write the styles into a STYLE tag in the document header and see if that works. If so, I would suspect a problem with the LINK tag or the sequence in which stuff is created. Hope this helps.

  8. #8
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with dynamic style sheet (VB 6)

    Yes, that line of code I wrote does give you the whole document.

    I've tried all different kinds of sequences and unfortunately could not get it to work. I will say that I am first loading a skeleton document (has lots of DIV tags). I've tried after that to add on the style sheet and then I've set the innerHTML of the DIV tags. This didn't work for me; nor did applying styles after setting innerHTML. I wonder if the stylesheet needs to be added before I even insert the skeleton doc.

    Chad

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Problem with dynamic style sheet (VB 6)

    Rather than use a LINK tag, try creating your style definitions within a STYLE element inside the HTMLHeadElement in the early stages of defining the document. I think there is some kind of problem using an external style sheet in this case, but it's just a hunch.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •