Popup

A container that appears in a child window. The popup window does not have any special frame. Popups can be displayed when an element is clicked by assigning the id of the popup to either the popup, context or tooltip attribute of the element. A popup is a type of box that defaults to vertical orientation.

More information about popup

The popup element implements the following interfaces:

nsIAccessibleProvider   nsIDOMXULPopupElement  

Attributes:

ignorekeys left onpopuphidden onpopuphiding onpopupshowing
onpopupshown position top

Properties and Methods:

accessible hidePopup moveTo popupBoxObject position
showPopup sizeTo

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

ignorekeys

Type: boolean

If true, keyboard navigation between menu items in the popup is disabled.

left

Type: integer

Overrides the horizontal position of the popup specified by the showPopup function.

onpopuphidden

Type: script code

This event is sent to a popup after it has been hidden.

onpopuphiding

Type: script code

This event is sent to a popup when it is about to be hidden.

onpopupshowing

Type: script code

This event is sent to a popup just before it is popped open. This handler is usually used to dynamically set the contents when the user requests to display it. Returning false from this event handler prevents the popup from appearing.

onpopupshown

Type: script code

This is event is sent to a popup after it has been opened, much like the onload event is sent to a window when it is opened.

position

Type: one of the values below

The position attribute determines where the popup appears relative to the element the user clicked to invoke the popup.

top

Type: integer

Overrides the vertical position of the popup specified by the showPopup function.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessible

Type: nsIAccessible

Returns the accessibility object for the popup.

hidePopup ( )

Return Type: no return value

Closes the popup window immediately.

moveTo ( x , y )

Return Type: no return value

Moves the popup to a new location.

popupBoxObject

Type: nsIPopupBoxObject

This read-only property holds the nsIPopupBoxObject that implements the popup. You wouldn't normally need to use this property as all of its functions are available via the popup itself.

position

Type: one of the values below

The position attribute determines where the popup appears relative to the element the user clicked to invoke the popup.

showPopup ( element, x , y , popupType, anchor, align )

Return Type: no return value

Opens a popup window. There are two ways of specifying where the popup appears, either at a specific screen position, or relative to some element in the window. If either x and y are set to values, the popup will appear at the screen coordinate (x,y). If x and y are -1, the popup will be positioned relative to the element specified as the first argument. This is what you might do to show a popup underneath a button for example. In this latter case, the anchor and align arguments may be used to further control where the popup appears relative to the element. The anchor argument corresponds to the popupanchor attribute on the element. The align argument corresponds to the popupalign attribute on the element. The anchor and align attributes are ignored if either x or y are not -1.

To have a popup appear relative to another element yet still be offset by some number of pixels, determine the actual screen position of the element using the boxObject.screenX and boxObject.screenY properties of the element and use those as the x and y arguments offset by the desired values.

Type should be either the string "popup", "context" or "tooltip". Each type of popup is intended to be displayed only temporarily; they are not excepted to be displayed permanently. Only one popup may be displayed at a time.

sizeTo ( width , height )

Return Type: no return value

Changes the current size of the popup to a new width and height.

Add a note User Contributed Notes
June 26, 2005, 5:29 am special dot michael at gmail dot com
showPopup doesn't really like html elements either, i ended up having to put a statusbar icon in, use that as the anchor for the popup, then calculate the middle of the browser and popup there.
October 22, 2004, 6:51 pm artntek at gmail dot com
> A bug causes popups opened with showPopup to appear
> relative to the screen rather than the desired element...

I still couldn't get this to work within an XBL binding, even after explictly setting document.popupNode

The workaround was to use x,y coordinates determined from the source element using boxObject:
var xCoord = element.boxObject.x;
var yCoord = element.boxObject.y + element.boxObject.height;
numeric_keypad_popup.showPopup(
element, xCoord, yCoord, "bottomleft", "topleft");
August 3, 2004, 10:48 pm mook dot moz at gmail dot com
For some reason, for me showPopup only showed at the specified position (in screen coordinates, in pixels) if I gave document.documentElement as the first parameter (element) - when null was used, the popup was shown at (0,0) instead.
June 18, 2004, 2:18 pm enndeakin at sympatico dot ca
A bug causes popups opened with showPopup to appear relative to the screen rather than the desired element until an automatic popup is opened and from then on, the popup appears in the right place. (An automatic popup is one that opens due to the popup or context attributes). This occurs because document.popupNode is not initialized.

You can workaround this bug by explictly setting document.popupNode to the relative node, generally the same value as the first argument to showPopup, before calling showPopup.
February 7, 2004, 3:12 pm starwed at yahoo dot com
To obtain a reference to the element which opened the popup, use document.popupNode.
http://www.xulplanet.com/references/elemref/ref_XULDocument.html

Copyright © 1999 - 2005 XULPlanet.com