We help IT Professionals succeed at work.
Get Started

IE7 javascript createDocument issue :(

blandyuk
blandyuk asked
on
2,132 Views
Last Modified: 2007-12-19
Hi Experts,

I have a problem where the below javascript wont work with IE7 :( I keep getting:
"Object doesn;t support this property or method"

Works fine in IE6 and Firefox. You'll see the alerts I've inserted to debug it. The problem line is:
"rt = document.implementation.createDocument('','',null);"

Any help will be great. Thanks.

Code:
---------------------------------------------------------------------
function SoapService()
{      
      //branch for Mozilla
      if (window.XMLHttpRequest)
      {
        this.XmlHttp = new XMLHttpRequest();
            if (this.XmlHttp.overrideMimeType) {
                  this.XmlHttp.overrideMimeType('text/xml');
            }

        this.Version=0;
    }
    // branch for IE6 / Windows ActiveX version
    else if (window.ActiveXObject)
    {
            this.XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            this.Version=1;
      }
      this.callService=_callService;
}
function _callService(func,params,async)
{
try{
      this.XmlHttp.open("POST", params[0], async);
      this.XmlHttp.setRequestHeader('Content-Type','text/xml; charset=UTF-8');
      this.XmlHttp.setRequestHeader('SOAPAction', '"'+params[1]+'"');
      var rt;
      if(async)
      {
            var XmlHttpAsync=this.XmlHttp;
            var VersionAsync=this.Version;
            this.XmlHttp.onreadystatechange =function()
            {
                  if(XmlHttpAsync.readyState != 4)return;
                  //alert(XmlHttpAsync.responseText);
                  if(VersionAsync==0)
                  {
                        rt = document.implementation.createDocument('','',null);
                        rt=XmlHttpAsync.responseXML;
                  }
                  else if(VersionAsync==1)
                  {
                        rt= XmlHttpAsync.responseXML.documentElement;
                  }
                  func(rt);
                  return true;

            }
      }
      this.XmlHttp.send(params[2]);
      if(!async)
      {
            //alert(this.XmlHttp.responseText);
            if(this.Version==0)
            {
                  alert('LOOK AT THIS!! START');
                  rt = document.implementation.createDocument('','',null);
                  alert('LOOK AT THIS!! MID');
                  rt=this.XmlHttp.responseXML;
                  alert('LOOK AT THIS!! FIN');
            }
            else if(this.Version==1)
            {
                  rt= this.XmlHttp.responseXML.documentElement;
            }
            func(rt);
            return true;
      }
}
catch(e){
            alert(e.description);
            return false;
}
}
function XmlRegExp(IrregExp)
{
      var strXml=IrregExp.toString();
      return strXml.replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
Comment
Watch Question
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE