Creating sidebar: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
mNo edit summary
m (Dev : Extensions : Example Code : Opening Sidebar moved to Creating sidebar)
(No difference)

Revision as of 19:50, 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