blandyuk
asked on
IE7 javascript createDocument issue :(
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.cr eateDocume nt('','',n ull);"
Any help will be great. Thanks.
Code:
-------------------------- ---------- ---------- ---------- ---------- ---
function SoapService()
{
//branch for Mozilla
if (window.XMLHttpRequest)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime Type) {
this.XmlHttp.overrideMimeT ype('text/ xml');
}
this.Version=0;
}
// branch for IE6 / Windows ActiveX version
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X MLHTTP");
this.Version=1;
}
this.callService=_callServ ice;
}
function _callService(func,params,a sync)
{
try{
this.XmlHttp.open("POST", params[0], async);
this.XmlHttp.setRequestHea der('Conte nt-Type',' text/xml; charset=UTF-8');
this.XmlHttp.setRequestHea der('SOAPA ction', '"'+params[1]+'"');
var rt;
if(async)
{
var XmlHttpAsync=this.XmlHttp;
var VersionAsync=this.Version;
this.XmlHttp.onreadystatec hange =function()
{
if(XmlHttpAsync.readyState != 4)return;
//alert(XmlHttpAsync.respo nseText);
if(VersionAsync==0)
{
rt = document.implementation.cr eateDocume nt('','',n ull);
rt=XmlHttpAsync.responseXM L;
}
else if(VersionAsync==1)
{
rt= XmlHttpAsync.responseXML.d ocumentEle ment;
}
func(rt);
return true;
}
}
this.XmlHttp.send(params[2 ]);
if(!async)
{
//alert(this.XmlHttp.respo nseText);
if(this.Version==0)
{
alert('LOOK AT THIS!! START');
rt = document.implementation.cr eateDocume nt('','',n ull);
alert('LOOK AT THIS!! MID');
rt=this.XmlHttp.responseXM L;
alert('LOOK AT THIS!! FIN');
}
else if(this.Version==1)
{
rt= this.XmlHttp.responseXML.d ocumentEle ment;
}
func(rt);
return true;
}
}
catch(e){
alert(e.description);
return false;
}
}
function XmlRegExp(IrregExp)
{
var strXml=IrregExp.toString() ;
return strXml.replace(/\&/g,"& ;").replac e(/</g,"&l t;").repla ce(/>/g,"& gt;");
}
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.cr
Any help will be great. Thanks.
Code:
--------------------------
function SoapService()
{
//branch for Mozilla
if (window.XMLHttpRequest)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime
this.XmlHttp.overrideMimeT
}
this.Version=0;
}
// branch for IE6 / Windows ActiveX version
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X
this.Version=1;
}
this.callService=_callServ
}
function _callService(func,params,a
{
try{
this.XmlHttp.open("POST", params[0], async);
this.XmlHttp.setRequestHea
this.XmlHttp.setRequestHea
var rt;
if(async)
{
var XmlHttpAsync=this.XmlHttp;
var VersionAsync=this.Version;
this.XmlHttp.onreadystatec
{
if(XmlHttpAsync.readyState
//alert(XmlHttpAsync.respo
if(VersionAsync==0)
{
rt = document.implementation.cr
rt=XmlHttpAsync.responseXM
}
else if(VersionAsync==1)
{
rt= XmlHttpAsync.responseXML.d
}
func(rt);
return true;
}
}
this.XmlHttp.send(params[2
if(!async)
{
//alert(this.XmlHttp.respo
if(this.Version==0)
{
alert('LOOK AT THIS!! START');
rt = document.implementation.cr
alert('LOOK AT THIS!! MID');
rt=this.XmlHttp.responseXM
alert('LOOK AT THIS!! FIN');
}
else if(this.Version==1)
{
rt= this.XmlHttp.responseXML.d
}
func(rt);
return true;
}
}
catch(e){
alert(e.description);
return false;
}
}
function XmlRegExp(IrregExp)
{
var strXml=IrregExp.toString()
return strXml.replace(/\&/g,"&
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or
this.version = (document.implementation)? 0:1;
if (window.XMLHttpRequest)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime Type) {
this.XmlHttp.overrideMimeT ype('text/ xml');
}
}
// branch for IE6 / Windows ActiveX version
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X MLHTTP");
}
this.version = (document.implementation)?
if (window.XMLHttpRequest)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime
this.XmlHttp.overrideMimeT
}
}
// branch for IE6 / Windows ActiveX version
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X
}
ASKER
Ah! I was missing the "document.implementation.c reateDocum ent" out of the "if" statement. My new code is:
-------------------------- ---------- --
if (document.implementation && document.implementation.cr eateDocume nt)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime Type) {
this.XmlHttp.overrideMimeT ype('text/ xml');
}
this.Version=0;
}
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X MLHTTP");
this.Version=1;
}
else
{
alert('Your browser can\'t handle this script');
return;
}
-------------------------- ---------- --
I did "Google" for ages with no success but sorted it now. Thanks mplungjan for that :)
--------------------------
if (document.implementation && document.implementation.cr
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime
this.XmlHttp.overrideMimeT
}
this.Version=0;
}
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X
this.Version=1;
}
else
{
alert('Your browser can\'t handle this script');
return;
}
--------------------------
I did "Google" for ages with no success but sorted it now. Thanks mplungjan for that :)
if (window.XMLHttpRequest && document.implementation)
{
this.XmlHttp = new XMLHttpRequest();
if (this.XmlHttp.overrideMime
this.XmlHttp.overrideMimeT
}
this.Version=0;
}
// branch for IE6 / Windows ActiveX version or IE7
else if (window.ActiveXObject)
{
this.XmlHttp=new ActiveXObject("Microsoft.X
this.Version=1;
}