When a user enters a bookmark using form[‘f3’] (a url and a title) it is immediately entered in via the dom – visually the title and the favicon are seen by the user. Each bookmark is a link and and image under div Bb1c. The insert is done alphabetically. Basically, I need to insert the new image and link after the previous one.
The loop portion was created before I had added in favicons so it loops through all the child elements, but it only needs to loop through the tags. How do I check to make sure that it is an element of type a before doing a compare? My for loop needs an && added to it.
This is rough draft code so if there anything else – contstructive criticism
var a=document.getElementById('Bb1c'),
b=document.createElement('a'),
e=document.createElement('img');
c=document.forms['f3'].elements,
d=a.firstChild,
b.innerHTML=c[1].value;
b.href=c[2].value;
b.name="a1";
b.className="b";
e.src=b.hostname + '/favicon.ico';
e.onerror=function()
{
e.src = 'http://www.archemarks.com/favicon.ico';
}
while(d=d.nextSibling)
{
if(b.innerHTML<d.innerHTML)
{
break;
}
}
a.insertBefore(b,d);
return 1;
}
You want the
tagName(ornodeName) property.: