Results 1 to 9 of 9

Thread: Code for line spaces in popup window

  1. #1
    Join Date
    Nov 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Code for line spaces in popup window

    I want to have a popup that looks like this.

    This is the first line in the popup window.


    This is the second line. Notice that it's two carriage returns lower than the first line
    .

    I'm using CoolTip's var feature where the script is above the <body>

    What I have is:

    <SCRIPT TYPE="text/javascript">
    <!--
    var cd_width=300;
    var cd_bgcolor='#7D725E';
    var cd_fgcolor='#AFA$84';
    var cd_closecolor='#F1ECE6';
    var cd_textcolor='ffffff';
    var cd_textalign='left';
    var cd_capalign='left';
    var cd_textsize='12px';
    var cd_vpos;
    var cd_cellpad='15px';
    //-->
    </SCRIPT>

    but I don't know what script to use for line spaces. I've been using <br><br> which works fine, however, I have a new template and am trying to have it work for all common browsers and so I tried W3 Validator and it says two <br>'s in sequence is a no no.

    Also, the var cd_cellpad='15px'; and var cd_vpos; aren't correct. I'm not too savvy about these things. I'm a copy-paste from examples kind of guy.

    Any tips?

    Thanks,
    Kerry

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The validator doesn't work too well on script code. It is meant for HTML. There are tricks you can use if having that green 'you've been a good boy' screen pop up in the validator is important to you. Generally, making scripts external or commenting them out using the:

    Code:
    <script type="text/javascript">
    <!--
    
    code goes here
    
    // -->
    </script>
    convention works. Making scripts external is the preferred method. About the BR tag, try:

    HTML Code:
    <br>&nbsp;<br>
    There is a way around just about everything the validator 'doesn't like' but, it is better to learn how to code to standards and not worry about the validator too much. It is most useful as a sort of 'dumb' proofreader type tool.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    I tried "<br>&nbsp;<br>" (no quotes) and the Validator gave me.

    Error Line 34 column 165: document type does not allow element "br" here.
    The message board is password protected.<br>&nbsp;<br>Each message board post generates feedback from the coach.

    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).


    Maybe I should just go back to using <br><br> and just live with the 76 errors.

    Kerry

  4. #4
    Join Date
    Nov 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John, I forgot to ask you what the correct way to do cd_cellpad.

    I have var cd_cellpad='15px'; but it doesn't work. The example doesn't show what to put after "cd_cellpad"

    Thanks, Kerry

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To tell you the truth, I don't think I've ever seen this particular script. However, since cd_width variable is configured as an integer without quotes or units, that implies that it is a 'stand-in' for the width attribute, not the width style property. There's no reason why this shouldn't also be true of cd_cellpad, as cellpadding is also an attribute. Try just:

    Code:
    var cd_cellpad=15;
    These validator issues are hard to resolve without seeing the whole page. If the element that has the text in it that you want to have double spaced has a class selector, you could set its line-height property to like 250% or so and see what happens. Then you should be able to skip the two <br>'s but, those are valid tags, depending upon the DTD (document type declaration or DOCTYPE). You should not mix self closing tags:

    <br />

    with tags that imply self closing:

    <br>

    in the same document. Which kind that you need to use is determined by the DTD.

    If tags are generated by javascript and it is the coding for doing this that is raising the red flag for the validator, you usually can simply escape the closing slash, ex:

    Code:
    document.write('<p>Some text<\/p>')
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Kerry
    I want to have a popup that looks like this.

    This is the first line in the popup window.


    This is the second line. Notice that it's two carriage returns lower than the first line
    .
    To increase the vertical distance between lines, use the line-height CSS property. To increase the distance between elements (such as paragraphs), use CSS margins. Whether that applicable depends on the code you're using; you haven't provided a link so I couldn't say.

    <SCRIPT TYPE="text/javascript">
    <!--
    Omit the comment delimiters (<!-- -->). They haven't been necessary for years, nor are they a solution to validation issues (John).

    but I don't know what script to use for line spaces. I've been using <br><br> which works fine, however, I have a new template and am trying to have it work for all common browsers and so I tried W3 Validator and it says two <br>'s in sequence is a no no.
    The validator won't say that because two consecutive forced line breaks is not syntactically wrong. However, it is abuse of the element. Vertical spacing should be achieved as I described at the beginning of this post. The br element should be reserved solely to break lines; in poetry or a postal address, for instance.

    I tried "<br>&nbsp;<br>" (no quotes) and the Validator gave me.

    Error Line 34 column 165: document type does not allow element "br" here.
    What that's telling you is that you're using an inline element where one is not permitted. That is, inline elements are not part of the allowed content model. But, that said, this could be the result of a prior error. Without a link, or some context, it's not really possible to say with certainty.


    Quote Originally Posted by jscheuer1
    ... DTD (document type declaration or DOCTYPE).
    DTD stands for document type definition. It is the document referenced by the document type declaration (or DOCTYPE).

    Mike

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Hey Mike, long time no see, welcome back! Yes, I agree about those silly

    <!-

    // -->

    comments in scripts but, they often do the job for the validator. As I did mention though, the preferred method is to make the script external. I have also had a lot of success just escaping the closing slashes on HTML code tags that appear in strings or as parts of mixed variables. The validator seems to ignore opening element tags inside of scripts and then gets upset when it sees the (unescaped) closing tags.

    Thanks for the clarification on DTD.

    I noticed we appear to agree on using the line-height style property for this, if available - and on the fact that it is hard to determine the exact cause of validator reported errors if the source code that elicited them is unavailable for examination. Oh, and on the fact that a <br> tag is valid.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Hey Mike, long time no see, welcome back!
    Hi, John.

    [Using markup comments] often do the job for the validator.
    The only reason (that I can think of) why an SGML processor should find the contents of a script element invalid is if it encounters the sequence "</" without it being followed by "script>" - the end-tag for the script element. As you pointed out yourself, this can be solved when embedding markup in a script by including a backslash before the forward slash, therefore breaking apart the ETAGO (end-tag open).

    The validator seems to ignore opening element tags inside of scripts and then gets upset when it sees the (unescaped) closing tags.
    As described in Appendix B, section 3.2 Specifying non-HTML data, an element may be considered to end as soon as ETAGO (</) is encountered, followed by a name start character (A-Za-z), even if that end-tag isn't actually a script end-tag. This might seem a little odd, but one must remember that end-tags can be implied if that end-tag is optional. However, because the end-tag for a script element is required, encountering another is an error.

    Mike

  9. #9
    Join Date
    Nov 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you. I'm not receiving email notifications of your replies so I'm a bit late reading these replies.

    Thank you, I'll work with what you've given me and let you all know the results.

    Thank you,

    Kerry

Bookmarks

Posting Permissions

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