I’m using some code in a Firefox extension to display the bookmarks of an user but it’s not working (the text “some text” appears on the page but not the bookmarks), does someone know why ?
the code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Page displayed when a user opens a new tab or window</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function init() {
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;
query.setFolders([toolbarFolder], 1);
var result = historyService.executeQuery(query, options);
var rootNode = result.root;
rootNode.containerOpen = true;
// iterate over the immediate children of this folder and dump to console
output.innerHTML+='test';
for (var i = 0; i < rootNode.childCount; i ++) {
var node = rootNode.getChild(i);
output.innerHTML+='test'; // not working
output.innerHTML+=("Child: " + node.title + "\n"); //not working
//dump("Child: " + node.title + "\n"); not working
}
// close a container after using it!
rootNode.containerOpen = false
}
</script>
</head>
<body onload="init()">
<p>Some text<p>
<div id="output">
</div>
</body>
</html>
Adding the code to the overlay file, it works ! (to see the entire extension Firefox extension not working)
code :