Firefox Vs IE compatibility issues

Below table depicts the common code changes that are required for FF compatibility in comparison with IE

IE Supported Code

FF Supported Code

Width, height gets inherited even if not specified

Need to specify width and Height otherwise doesn’t get inherited

Custom Properties can be directly accessed

eg : .folderId

Custom Properties can be accessed only by getAttribute("property name')

eg:  getAttribute('folderid')

.InnerText works in IE

Instead  use    .textContent

event.srcElement supported by IE only

event.target in FF also need to pass ‘event’ attribute explicitly

 eg:  onclick="methodName(event);" -

SelectNodes() works in IE

 

SelectNodes() for paths starting with "\\pathName"

The following code needs to be used for SelectNodes() var xmlNodesFF = dom.getElementsByTagName(xPath);

           

for (var n = 0; n < xmlNodesFF.length; n++)

            {

                var getXmlAttributes = dom.getElementsByTagName(xPath)[n].attributes;

                var selectXmlAttribute = getXmlAttributes.getNamedItem(attributeName).value;

                if (selectXmlAttribute == idValue)

                {

                    selectNodesObj[i] = dom.getElementsByTagName(xPath)[n];

                    i = i + 1;

                }

                else if (idValue == " " && attributeName == " ")// get all values

                {

                    selectNodesObj[i] = dom.getElementsByTagName(xPath)[n];

                    i = i + 1;

                }

var i = 0;

            var isMatch;

            var xmlNodesFF = dom.getElementsByTagName(xPath);

            for (var n = 0; n < xmlNodesFF.length; n++)

            {

                var getXmlAttributes = dom.getElementsByTagName(xPath)[n].attributes;

                for (var cnt = 0; cnt < idValues.length; cnt++)

                {

                    isMatch = false;

                    var selectXmlAttribute = getXmlAttributes.getNamedItem(attributeNames[cnt]).value;

                    if (selectXmlAttribute == idValues[cnt])

                    {

                        isMatch = true;

                    }

                    if (isMatch == false)

                    {

                        break;

                    }

                }

                if (isMatch == true)

                {

                    selectNodesObj[i] = dom.getElementsByTagName(xPath)[n];

                    i = i + 1;

                }

Creating XML DOM object in IE is

xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

Creating XML DOM object in FF is

xmlDoc  = document.implementation.createDocument("","doc",null);

 

to getattribute in IE

xmlNode.getAttribute("Attribute Name");

 

 

 

In FF

xmlNode.attributes["Attribute Name"].value;

.xml attributes is defined in IE

Need to use (new XMLSerializer()).serializeToString(xmlObject); to get the xml string

Setting Attribute : Node.setAttribute(attributeName) = value;

Setting  Attribute :

Node.setAttribute(attributeName, attributeValue);

.Text works in IE

use .textContent to set and get text values

Width and height rendering differs in IE and FF because of the size

Width n height rendering differs in IE and FF because of the size

NodeTypeString exists in IE not in FF

NodeTypeString  undefined in FF use nodeType as it works for both IE and FF(nodeType = 1 defines ‘element’)

To loadXML from xml string as input , IE uses LoadXML(xmlstring)

FF uses

var parser = new DOMParser()
        xmlDoc = parser.parseFromString(xmlstring, "application/xml");

author

Vinay Jagtap

A hard core Technocrat with over a decade of extensive experience in heading complex test projects coupled with real time experience of project management and thought leadership. Extensive experience in Performance, Security and Automation Testing and development of automation frameworks and ability to setup and execute Global service centers and Center of Excellences for testing.

Get Free Email Updates to your Inbox!

www.CodeNirvana.in

Powered by Blogger.

Translate

Total Pageviews

Copyright © T R I A G E D T E S T E R