0

I need to append a DIV element into xul:browser and make position: absolute; and move this DIV around in firefox window. Is it possible? How can i do this in a firefox extension?

3 Answers3

1

If you position your element(s) inside of a <stack>, the top,right,bottom, and left attributes can be used for positioning.

Brian
  • 25,523
  • 18
  • 82
  • 173
0

After searching the web and working around styles i figured it out that i can use position: fixed; style

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://helloworld/skin/overlay.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://helloworld/locale/overlay.dtd">
<overlay id="helloworld-overlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml">

    <vbox id="browser-panel">
        <html:div style="position: fixed; top: 20px; left: 50px;">
                  <html:img src="https://static.addons.mozilla.net/en-US/developers/docs/sdk/1.1/media/firefox-logo.png" width="32" height="32" />
        </html:div>
    </vbox>

</overlay>
0

XUL uses the flexible box model, you won't get very far with absolute positioning there. The best solution would be using the <xul:panel> element that is meant to be displayed on top of other content (similar to context menu or tooltip). There is a moveTo() method that allows the panel to be moved after it was opened.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
  • I though of panel myself, but didnt use cause i think we have focus issues(user clicks on some parts of program) or box model issues (what if i wanted to show a cursor? i dont want shadow or any style of a panel box). These was the reason i didnt test `xul:panel`. Am i right? if not, can a `xul:panel` stay on top of EVERY other panels like `Save As...` or `Downloads` because this absolute DIV i used, cannot go on top of other windows. –  Apr 17 '12 at 13:14
  • A panel can have focus and it can have text fields in it (see for example "Edit this bookmark" panel in Firefox). The shadow is definitely optional, I think that `-moz-appearance` CSS property is controlling it. And - yes, a panel displays on top of everything else. – Wladimir Palant Apr 17 '12 at 14:43