Placing the new links after the original ones

in
Subscribe to Placing the new links after the original ones 5 posts, 2 voices



ptmb Scriptwright

Hi, I really like this script, but I have a tiny question to do:

Could you make the new forum and blog links go after the original navigation links? Maybe something like an option to choose between both?
It would be as easy as to replace:

var ul = document.getElementById("navigation"), li =
document.createElement("li");
ul.insertBefore(forumlink_li, ul.getElementsByTagName("li")[0]);
ul.insertBefore(bloglink_li, ul.getElementsByTagName("li")[0]);

with

var ul = document.getElementById("navigation");
ul.appendChild(bloglink_li);
ul.appendChild(forumlink_li);

I really like the script and hope you consider my suggestion.

 
whatrevolution Script's Author

However strange this may seem, when I use:

ul.appendChild(forumlink_li);
ul.appendChild(bloglink_li);

My links appear to the left of the list (before the original links).

When I use:

ul.insertBefore(forumlink_li, ul.getElementsByTagName("li")[0]);
ul.insertBefore(bloglink_li, ul.getElementsByTagName("li")[0]);

The two new links appear to the right (the end) of the original list.

This is why I chose the insertBefore() function, originally.

 
ptmb Scriptwright

Now that is strange... In here, it is exactly the opposite, and in theory the code you use should make it as is happening to me...

When I enter var ul = document.getElementById("navigation") on firebug, followed by ul.getElementsByTagName("li")[0], it returns the first li element, so, inserting the new childs before the first li element, should cause the new childs to go to the left end of the list, as it is happening to me.

Now, using appendChild() should add the items to the end of the list. As I am doing in my modified code.

Have you checked if you have any special CSS in stylish that is modifying the position taken by the li elements? I think there is some sort of Mozilla special property that does that, this one.

Weird :/

 
whatrevolution Script's Author

Good thought; you were right that my CSS in http://userstyles.org/styles/3866 is modifying the list order. Probably the absolute positioning.

 
ptmb Scriptwright

Actually, for what I read of the style, I think the problem is in

#navigation > li
  {
    float: right !important;
  }

that inverts the order of the list (from left to right to right to left).

I think the solution for who doesn't want to invert the links order but want to keep the new "Blog" and "Forum" links to the right, is to provide some switch in the script, something like:

// Change the links order so they are placed on the left or on the right
var LinksOnRight = true;

and use different code according to it being true or false.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel