Im making firefox extension. One function stores value in every tab, to use it later by other function.
function setValue(value) {
var attr = gBrowser.document.createAttribute("value");
attr.value = value;
gBrowser.document.attributes.setNamedItem(attr);
};
function getValue() {
var attr = gBrowser.document.attributes.getNamedItem("value");
if (attr != undefined && attr != null)
return attr.value;
else
return null;
};
For some reason, this doesn’t work. Can you spot an error in my code?
Function getValue() should get value of active tab.
There are more errors than code here:
gBrowser.document– you probably meantgBrowser.ownerDocumentor justdocument(equivalent but simpler).gBrowser.document.attributes, you meantgBrowser.attributes.attributesseems very weird, an equivalent to the fixed up version of your code would begBrowser.setAttribute("value", value)andgBrowser.getAttribute("value")gBrowser.mCurrentTab.setAttribute?)