View Full Version : Box not working

08-31-2010, 05:10 AM
In my website, I have a script that I need help to get working. This is my script.

<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>

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.

Old Pedant
08-31-2010, 08:25 AM
What is the code surrounding this???

It would *HAVE* to be

<table ...>
<td>one or more</td>
<td>of these</td>
...now your code...
...more rows...

or something like that. Else it would never work.

Old Pedant
08-31-2010, 08:31 AM
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:

'<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>' );


<style type="text/css">
td.custom1 { ... }
td.custom2 { ... }

and it will be a lot simpler and you won't have quote nesting problems.