Results 1 to 2 of 2

Thread: Adding a <UL> and <a>'s using the DOM (document object model)

  1. #1

    Thread Starter
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Arrow 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

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width