git-svn-id: svn://euphorik.ch/pompage@45 02bbb61a-6d21-0410-aba0-cb053bdfd66a
[pompage.git] / doc / webdeveloper / common / history.js
1 // Adds an href to the history
2 function webdeveloper_addToHistory(href)
3 {
4 // If the href is set
5 if(href)
6 {
7 var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory);
8
9 // If the href is not already in the history
10 if(!globalHistory.isVisited(href))
11 {
12 globalHistory.addPage(href);
13 }
14 }
15 }
16
17 // Clears the history
18 function webdeveloper_removeAllFromHistory()
19 {
20 Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIBrowserHistory).removeAllPages();
21 }
22
23 // Removes an href from the history
24 function webdeveloper_removeFromHistory(href)
25 {
26 // If the href is set
27 if(href)
28 {
29 var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory);
30
31 // If the href is in the history
32 if(globalHistory.isVisited(href))
33 {
34 Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIBrowserHistory).removePage(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(href, null, null));
35 }
36 }
37 }