0

I have found several posts about this topic, but unfortunately none that work (probably because I'm missing something).

My page includes the following:

<footer>
  <script type="text/javascript" src="/js/footer.js"></script>
</footer>

footer.js will have a hash with the names and targets of some links, then loop over the hash and create the list with this data and insert it into the document. The reason for the external JS file is that it will be used on every page in the site.

This post seems to be similar: How can I dynamically create an unordered list in JavaScript?

But when I tried the posted solutions I got no output in the browser.

I'm willing to use an existing script to create a menu if I don't have to actually write out the HTML of the list in the page (i.e. if I can create the structure of the list in footer.js and then use another script on it, like tinynav.js).

3
  • Use Firebug to see if the file is loaded (under Net tab). Commented Jun 7, 2012 at 0:58
  • The file is loaded. If I put document.write(list), the contents will show up, but the list data doesn't. Commented Jun 7, 2012 at 2:48
  • Sorry, but I have to clarify where do you put document.write(list)? is it in the footer.js? Are you referring to an element in your footer.js? If that is the case, the object may not have been rendered when footer.js is executed. Commented Jun 7, 2012 at 6:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.