Those two links in your post are both to the same page. But I think I see what you're trying to do anyway. If I write all three scripts to the page I see that this and only this:
Code:
' <li id="leftnavli"><A href="#" class="leftnav">News Link 1</A></li>'
+ ' <li id="leftnavli"><A href="#" class="leftnav">News Link 2</A></li>'
+ ' <li id="leftnavli"><A href="#" class="leftnav">News Link 3</A></li>'
appears three times, once in each of them.
Before I give you an answer, there are at least three problems with what you already have:
- There can only be one element per page with a given id. If this is violated for styling purposes only, browsers will have no problem. However, if in javascript you later try to manipulate, or even find these elements by their id, there will almost certainly be problems.
- The attribute
language="JavaScript" of your script tags has been deprecated. It's no longer required, and will cause problems in some situations. The attribute type="text/javascript" is required in all modern DOCTYPES, except HTML 5, where it's the default if none is specified. You use a DOCTYPE that requires this attribute for the script tag.
- The newslistings.js script writes out invalid HTML code (li's with no parent ul element).
Depending upon what you do in the future, #1 is potentially the most serious, though some browsers might ignore your scripts entirely now due to #2. The 3rd issue could be fixed by inluding the opening and closing ul tags in the variable newslinks and removing these tags from the two scripts that have them in the code below.
OK, here's a solution, make another script. Let's call it newsItems.js, and in it we put:
Code:
var newslinks = ' <li id="leftnavli"><A href="#" class="leftnav">News Link 1</A></li>'
+ ' <li id="leftnavli"><A href="#" class="leftnav">News Link 2</A></li>'
+ ' <li id="leftnavli"><A href="#" class="leftnav">News Link 3</A></li>';
Put the script tag for it on the page before any of the other three scripts.
Change leftsidenewsfacts.js to:
Code:
document.write('<div id="left_blue_table"><ul id="leftnavulblue">'
+ newslinks
+ ' </ul>'
+ ' </div><img src="http://www.arrow.com/images/bluesidenavftrGRY.gif"><div style="background-image:url(http://www.arrow.com/images/bluesidebtmGRYbkgrnd.gif); background-repeat:repeat-y; width:185px; padding-top:0px; padding-bottom:0px">'
+ ' '
+ ' '
+ ' <table width="175" border="0" cellpadding="0" cellspacing="0">'
+ ' <tr><td width="5px" height="0"> </td>'
+ ' <td colspan="2"><strong>Fast Facts</strong><br><br></td></tr>'
+ ' <tr><td width="10px"> </td><td width="5"> </td><td width="159" style="font-size:7pt"><strong>Ticker Symbol: </strong><br>'
+ ' <strong>2008 Sales:</strong> $1 billion<br>'
+ ' <strong>Worldwide locations:</strong> 150<br>'
+ ' <strong>Fortune 500 Ranking:</strong> <br>'
+ ' <strong>Suppliers Worldwide:</strong> 600<br>'
+ ' <strong>Customers Worldwide:</strong> 100,000<br>'
+ ' <strong>Industry:</strong> <br>'
+ ' <strong>Founded: </strong><br>'
+ ' <strong>Incorporates:</strong>1946<br>'
+ ' <strong>Public:</strong> 1961<br></td></tr></table><br><img src="http://www.arrow.com/images/bluesidebtmGRYbtm.gif"></div>');
Change leftsidenews.js to:
Code:
document.write('<div id="left_blue_table"><ul id="leftnavulblue">'
+ newslinks
+ ' </ul><img src="http://www.arrow.com/images/bluesidenavftr.gif"></div>');
and newslistings.js to:
Code:
document.write(newslinks);
Notes: I said this is 'an answer', 'a solution'. That's because there are other ways of going about this. I believe this approach is the closest to what you already are doing though. It might not be the best. It doesn't correct the use of multiple elements with the same id. Since doing so would affect your style, I will leave it to you to fix that. I would suggest changing id="leftnavli" to class="leftnavli" and then changing:
Code:
#leftnavli {
padding-right: 0px;
padding-left: 0px;
margin-bottom: 10px;
padding-bottom: 0px;
padding-top: 0px;
list-style-type: none
}
to:
Code:
.leftnavli {
padding-right: 0px;
padding-left: 0px;
margin-bottom: 10px;
padding-bottom: 0px;
padding-top: 0px;
list-style-type: none
}
Something similar should also be done about the use of the ids left_blue_table and leftnavulblue.
Bookmarks