MozillaZine

Creating sidebar

From MozillaZine Knowledge Base

(Difference between revisions)
Revision as of 19:48, 22 September 2005
Asqueella (Talk | contribs)
(category)
<-- Previous diff
Revision as of 19:49, 22 September 2005
Asqueella (Talk | contribs)

Next diff -->
Line 1: Line 1:
-This is how to open a sidebar using javascript and xul. The first file is the xul file:+{{extdev}}
 + 
 +This is how to add a sidebar (and a menu item to open it) using JavaScript and XUL. The first file is the XUL file:
<broadcasterset id="mainBroadcasterSet"> <broadcasterset id="mainBroadcasterSet">

Revision as of 19:49, 22 September 2005

This page is part of the extension development documentation project.

Ask your questions in MozillaZine Forums. Also try browsing example code.

Note: development documentation is in process of being moved to Mozilla Development Center (MDC).

This is how to add a sidebar (and a menu item to open it) using JavaScript and XUL. The first file is the XUL file:

<broadcasterset id="mainBroadcasterSet">
	<broadcaster id="nameofSidebar"
		autoCheck="false"
		label="label"
		type="checkbox" 
		group="sidebar"
		sidebarurl=""
		sidebartitle="title"
		oncommand="openSidebar();"/>
</broadcasterset>
<popup id="contentAreaContextMenu">
	<menuitem id="openSideBar"
               label="Open Sidebar"
               accesskey=""
               oncommand="openSidebar();"/>
</popup>

Here is the js file:

function openSidebar(){
	var url="The url, chrome or http";
	var sidebar = document.getElementById('nameofSidebar')
	sidebar.setAttribute('sidebarurl',url);
	toggleSidebar('nameofSidebar');
}

Thanks to mozedit for this code