Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:34:22+00:00 2026-05-31T22:34:22+00:00

I’m trying to get the content from all the nodes in the bookmarks menu

  • 0

I’m trying to get the content from all the nodes in the bookmarks menu into textbox.value, but only the last bookmark appears. What am I doing wrong?

function AllBookmarks()
{
    var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
                                   .getService(Components.interfaces.nsINavHistoryService);
    var options = historyService.getNewQueryOptions();
    var query = historyService.getNewQuery();
    var bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
                                     .getService(Components.interfaces.nsINavBookmarksService);
    //var toolbarFolder = bookmarksService.toolbarFolder;
    //var bookmarksMenuFolder = bookmarksService.bookmarksMenuFolder;
    var unfiledBookmarksFolder = bookmarksService.unfiledBookmarksFolder;

    //query.setFolders([toolbarFolder], 1);
    //query.setFolders([bookmarksMenuFolder], 1);
    query.setFolders([unfiledBookmarksFolder], 1);

    var result = historyService.executeQuery(query, options);
    var rootNode = result.root;
    rootNode.containerOpen = true;

    // iterate over the immediate children of this folder
    for (var i = 0; i < rootNode.childCount; i ++) {
      var node = rootNode.getChild(i);
    }

    // close a container after using it!
    rootNode.containerOpen = false;
    var textbox = document.getElementById("MyExtension");
    var title= "Title: " + node.title; // shows the title of URL
    var url= "\nURL: " + node.uri; // shows the URL
    textbox.value = title + url + "\n";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:34:24+00:00Added an answer on May 31, 2026 at 10:34 pm

    In the loop commented as “iterate over the immediate children of this folder”, you are probably looping over each of the bookmarks correctly, but you are not doing anything with the each node before moving on to the next. As a result, the node variable is set to the last node when you leave the loop.

    Also, you are assigning to textbox.value, rather than appending to it, so even if you were acting on the data for each node you would have clobbered it each time, resulting in only the data of the last node (the same outcome!). If you want to build up a string like that, you have to append to it, not assign to it. One way to do this is with the += operator.

    So, the last part of the code should be something like:

    var textbox = document.getElementById("MyExtension");
    
    // iterate over the immediate children of this folder
    for (var i = 0; i < rootNode.childCount; i ++) {
      var node = rootNode.getChild(i);
      var title = "Title: " + node.title; // gets the title of URL
      var url = "\nURL: " + node.uri; // gets the URL
      textbox.value += title + ": " + url + "\n"; // note the += (append) operator
    }
    // close a container after using it!
    rootNode.containerOpen = false;
    

    NB: In many other (stricter) languages, your posted code wouldn’t compile because you’re using the variable node outside of the “scope” (the braces) in which it was declared. It is a good rule of thumb to follow voluntarily though: violating this guideline often means you’re making a mistake, or need to think more carefully about what you’re doing. In this very case, it may have alerted you to the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.