Useful resources for assignment 5
Adding HTML to a sidebar:
http://developer.mozilla.org/en/docs/...
(note: I had to wrap my HTML elements in a block-level HTML container, i.e. a div or span tag.)
--
Working with Mozilla's implementation of the DOM:
http://developer.mozilla.org/en/docs/...
--
Responding to the page load event:
http://developer.mozilla.org/en/docs/...
(note: you can just add Javascript within <script> tags in you firefox overlay XUL document)
--
Targeting links to the browser's main content area:
http://devedge-temp.mozilla.org/views...
(note: the page is pretty long and probably very out of date, but setting target="_content" worked for me.)
http://developer.mozilla.org/en/docs/...
(note: I had to wrap my HTML elements in a block-level HTML container, i.e. a div or span tag.)
--
Working with Mozilla's implementation of the DOM:
http://developer.mozilla.org/en/docs/...
--
Responding to the page load event:
http://developer.mozilla.org/en/docs/...
(note: you can just add Javascript within <script> tags in you firefox overlay XUL document)
--
Targeting links to the browser's main content area:
http://devedge-temp.mozilla.org/views...
(note: the page is pretty long and probably very out of date, but setting target="_content" worked for me.)
3
people like this idea
I like this idea!
Tell me when this idea gets some attention.
The more people who like this idea, the more it gets noticed.
The more people who like this idea, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Thanks for the sweet info :)
Do you have any hints on how to select and change the value of the element that displays the current page? I tried this, but it didn't do a thing:
onPageLoad: function(aEvent)
{
document.getElementById("currentPage").value = "Loaded"
}
Does it have anything to do with the fact that my Javascript is in the firefoxOverlay.xul file and the element I'm trying to change is in my sidebar.xul file?
1 person thinks
this is one of the best points
-
Inappropriate?I having this difficulty too.
If i place the javascripit in my sidebar xul file, it doesnt seem to recognize whenever a new page is loaded.
I suspect it will only recognize that a new page loaded when it actually loads within the sidebar. -
Inappropriate?Bryant:
You should be able to access the element; if you couldn't you'd most likely be getting something akin to a null pointer exception.
I looked in the Mozilla DOM documentation, but couldn't find an "element.value" attribute. The closest I could find is the "element.nodeValue," which returns null for all elements, and has no effect when set.
Rather than trying to assign the value directly to the node I prune all the children of the element, and then append a new new text node containing the updated label. Check out the following methods...
- element.hasChildNodes
- element.firstChild
- element.removeChild
- element.appendChild
- document.createTextNode
I suspect there's an easier way to achieve this.
--
Patrick:
I'm not sure what placing the Javascript in the sidebar xul will do; it sounds plausible that it's only run when the sidebar is open? -
Inappropriate?Im still having trouble just finding my sidebar elements. I use document.getElementById() but it keeps returning an element with no properties.
Does it matter that the element I'm looking for is in a different file?
im trying to find it in my firefoxOverlay.xul and the actual element is in my sidebarDemo.xul -
Inappropriate?to Bryant:
Look at this page:
http://developer.mozilla.org/en/docs/....xul_script
Code might be something like this:
var doc = document.getElementById("sidebar").contentDocument;
var val = doc.getElementById("urlLabel").value;
I have a problem with getting the URL of the main page. Could anyone help? I tried document.location.href, but it returns chrome://browser/content/browser.xul -
Inappropriate?alright i have this nearly working correctly. the way i finally got the script to correctly access and modify the label within the sidebar was doing something like this:
var newurl = document.createTextNode(doc.location.href);
var sidebarWindow = document.getElementById("sidebar"). contentDocument;
var newurllabel = sidebarWindow.getElementById("urllabel");
newurllabel.value = doc.location.href;
newurllabel.href = doc.location.href;
And you can make the label clickable by setting its style class to text-link like this:
<label class="text-link" value="No page loaded.">
The only problem remaining is that when you click this, it opens the page in a new browser window instead if in the current one. I'm not sure if there's a clean fix for this.</label> -
Inappropriate?Thanks everyone. This was all really useful :) I'm just having the same problem as Patrick where the browser is opening into a new one.
-
Inappropriate?Thanks for the hint. Unfortunately, my link does not work even if I hardcode the URL like this <label class="text-link" value="http://www.google.com">
Can anybody help?</label> -
Inappropriate?Never mind, I got it <label href="http://www.google.com" class="text-link" value="new page"> </label>
-
Inappropriate?oh btw in case anyone doesnt know QuickRestart
can really make developing on firefox easier -
Inappropriate?If you're having trouble with Firefox loading your extension, be sure your extension file is sitting inside the right profile path for your environment: http://kb.mozillazine.org/Profile_folder
On my mac (Leopard) for example, the full path ended up being ~/Library/Application Support/Firefox/Profiles/kfvw9w3u.default/extensions -
Inappropriate?Great tips! thanks!
Loading Profile...









EMPLOYEE