PDA

View Full Version : anybody knows about appendchild method??


shane_js
02-18-2008, 02:47 PM
i am making a extension for firefox where i am using this code snippet for creating an iframe and then appending it to the previously existing document
after that i load something in the iframe ...
but i don't know why after two or three loading my browser crashes !!
??????any help people !!!!?????????????
var iframe = document.createElement("iframe");
iframe.width = window.content.document.width;
iframe.height = 1;
iframe.style.margin = "0 0 0 -10000px";
iframe.style.position = "absolute";
iframe.style.top = 0;
iframe.style.left = 0;
document.body.appendChild(iframe);
iframe.addEventListener("load", function()
{
try{
var isNextExist = iframe.contentDocument.evaluate("//div[@id='nn']", iframe.contentDocument.body, null, 9, null).singleNodeValue;
var list = iframe.contentDocument.evaluate("//div[@class='g']", iframe.contentDocument.body, null, 6, null);
if (list.snapshotLength==0)
{
list = iframe.contentDocument.evaluate("//div[@id='ImgContent']/table/tbody/tr", iframe.contentDocument.body, null, 6, null);
}
for (var i = 0; i < list.snapshotLength; i++)
{
var item = list.snapshotItem(i);
storageContainer.appendChild(item);
}
if (!!isNextExist)
{
startNr += itemsQuantity;
} else
{
// add option to remove filter
var removefilter = iframe.contentDocument.evaluate("//a[contains(@href,'filter=0')]/parent::i/parent::p", iframe.contentDocument.body, null, 9, null).singleNodeValue;
if (removefilter)
{
storageContainer.appendChild(removefilter);
}
var n = storageContainer;
do
{
while (n.nextSibling)
{
n = n.nextSibling;
if (n.style && n.id != 'navbar') n.style.display = 'block';
}
n = n.parentNode;
} while (n);
}
iframe.src = "";
document.body.removeChild(iframe);
}catch(e)
{alert(e);
}
}
, false);
iframe.src = "http://"+window.content.location.host+window.content.location.pathname+query.replace(/start=\d*/,"start=" + startNr) + "#disable-userscript";


please help !!!!