Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Box not working

  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Box not working

    In my website, I have a script that I need help to get working. This is my script.
    Code:
    <script language="Javascript">
    <!--
    if (screen.width>=1024)
     {
    document.write('<td width="20%"><table border="0" cellpadding="0" cellspacing="0" width="162">
    <tr><td height="29" style="background:url("/Custom/Top2.png");color:#116111;" align="center"><b>Newest Tutorial</b></td></tr>
    <tr><td height="160" style="background:url("/Custom/Middle2.png") #000000;padding:5px 5px 0 5px;">$MYINF_8$</td></tr>
    <tr><td><img src="/Custom/Bottom2.png" border="0"></td></tr>
    </table>
    </td>');
     }
    //-->
    </script>
    It is supposed to detect if someone has a widescreen monitor, and then add the extra box if it is widescreen.
    For some unknown reason, its not working. No extra box appears. Does anyone know where I went wrong?

    Edit: $MYINF_8$ is what goes inside the box.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    What is the code surrounding this???

    It would *HAVE* to be
    Code:
    <table ...>
    <tr>
        <td>one or more</td>
        <td>of these</td>
    <script>
    ...now your code...
    </script>
    </tr>
    ...more rows...
    </table>
    or something like that. Else it would never work.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    Oh, you are hosed with that code.

    You have "..." *INSIDE* of "...".

    Won't ever work.

    I'd suggest setting up some styles for those two <td>s that need the backgrounds so that you can just do:
    Code:
    document.write(
        '<td width="20%">'
      + '<table border="0" cellpadding="0" cellspacing="0" width="162">'
      + '<tr><td class="custom1"><b>Newest Tutorial</b></td></tr>'
      + '<tr><td class="custom2">$MYINF_8$</td></tr>'
      + '<tr><td><img src="/Custom/Bottom2.png" border="0"></td></tr>'
      + '</table>'
      + '</td>' );
    Create
    Code:
    <style type="text/css">
    td.custom1 { ... }
    td.custom2 { ... }
    </style>
    and it will be a lot simpler and you won't have quote nesting problems.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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