|
-
Sep 22nd, 2008, 02:49 PM
#1
Thread Starter
Fanatic Member
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
Last edited by damasterjo; Sep 22nd, 2008 at 02:54 PM.
Software languages known:
Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
Software API's known:
Directx 7 and 8
Internet languages, in the process of learning:
HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX
-
Sep 24th, 2008, 07:31 AM
#2
Re: Adding a <UL> and <a>'s using the DOM (document object model)
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|