Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

DOM access issues in Firefox.

  • 13-09-2006 11:18am
    #1
    Closed Accounts Posts: 59 ✭✭


    Hi all,

    I have an AJAX/ DOM/XML/Javascript site that is working just fine in IE - however the Javascript that is accessing the DOM does not seem to be working in FF. I have put alert statements all over the code and where everything seems to be failing is in the 2 statements highlighed in red below:

    if (http_request.readyState == 4)
    { alert('step2');
    if (http_request.status == 200)
    { alert('step3');
    xmlDoc = http_request.responseXML;

    var info = xmlDoc.getElementsByTagName('para');




    for(i=0; i < info.length; i++)
    {

    alert('here1');
    var infoNode = info.item(i);
    if(infoNode != null && infoNode.hasChildNodes())
    {
    var infoPar = infoNode.getElementsByTagName('info');
    alert('here2');

    for(j=0; j<infoPar.length; j++)
    {
    alert('here3');
    var infoParNode = infoPar.item(j);

    var paragraph = infoParNode.getAttribute('paragraph');

    var infoBody = infoPar.item(j).text;

    //alert(infoPar.item(j));

    alert(infoBody);



    setInfoBody =''+openFormat+infoBody+closeFormat;


    openFormat='';
    closeFormat='';

    }

    heading = infoNode.childNodes(0).childNodes(0).data;

    alert(headings);
    setHead+='<a href="javascript:showInfo('+i+')" >'+heading+'</a><br>';
    setInfo = '<p><img src="symb.gif"> '+heading[0]+'</p><div id="body_container">'+setInfoBody[0]+'</div><br>';


    infoContainer.innerHTML = setInfo;

    }


    I've been trying different code all morning:
    i.e. changing .data and .text to .value or .innerHTML
    nothing seems to be working -
    Has anybody come across this problem before? All the stuff I've been reading contradicts whats happening - seems that IE is the problem for everyone else on the net!

    Thanks,
    Fi*

    }


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    If you custom install firefox it allows you to install a dom inspector. Might help in the debugging.


  • Registered Users, Registered Users 2 Posts: 26 ast


    I'm guessing here but try replacing

    var infoBody = infoPar.item(j).text;
    with
    var infoBody = infoPar[j].text;

    and

    heading = infoNode.childNodes(0).childNodes(0).data;
    with
    heading = infoNode.childNodes[0].childNodes[0].data;


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    Also:
    // workaround for internet explorer
    function getXmlNodeValue(xmlNode){
    	try{
    		if(XMLHttpRequest){
    			return xmlNode.textContent;
    		}
    	}catch(e){
    		try{
    			return xmlNode.text;
    		}catch(e){
    		}
    	}
    }
    
    The text property is an IE only thing. And what does the data property refer to?


  • Closed Accounts Posts: 59 ✭✭Fi_C**


    Thanks akari, using that text / textContent workaround worked well.
    I have also resolved the other issue .. just by chance -,
    I replaced
    heading = infoNode.childNodes(0).childNodes(0).data;

    with:
    if(window.XMLHttpRequest){
    heading = infoNode.firstChild.nextSibling.textContent;
    }
    else {
    heading = infoNode.childNodes(0).childNodes(0).data;
    }

    I don't know why this works ... :confused:
    It seems Mozilla sees the tree differently to IE - In Mozilla the node is seen as a sibling but in IE as a childNode?

    Oh well I don't care as long as it works ;)
    Thanks again for your help - I'm off to fix all the other wierd cross-browser issues that have just been revealed :(

    Regards,
    Fi**


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    It's not that Mozilla sees the tree differently to IE.

    It's that IE ignores the specifications, repeatedly. If you look at www.xulplanet.com you'll see an object reference with all of the specified objects and their methods and properties. It's not much by way of tutorial but it's a fantastic resource.

    Exploder just has its own way of doing things, as ever.


  • Advertisement
Advertisement