Adding a <UL> and <a>'s using the DOM (document object model)
Code:
HTML CODE
<div id="nav">
</div>
JAVASCRIPT CODE
function makeAutoLinks(){
contentEdit = document.getElementById("nav");
ul = document.createElement("ul");
li1 = document.createElement("li");
a1 = document.createElement("a");
a1.setattribute('href','index.html');
a1.appendChild(document.createTextNode('Home'));
contentEdit.appendChild(ul);
contentEdit.appendChild(li1);
contentEdit.appendChild(a1);
}
i am trying to make it where my page im working on all the links can be added dynamically so when i need to change a link on the site i dont have to change EVERY page.
www.disasterexpertsinc.com
thats the site, the news bar on the right and the stuff under the nav bar is added dynamically, i want to add the links to, the code above dosent work.
please advise what im doing wrong.
-damasterjo
Re: Adding a <UL> and <a>'s using the DOM (document object model)
Quote:
Originally Posted by damasterjo
please advise what im doing wrong.
Not using PHP.
You can get PHP to read the menu items from any location of your choice and it will display as normal links. With JavaScript, crawlers won't be able to see it and your pages on the site will never be visible.