More information:
With the introduction of mutable DOM prototypes (MDP) in IE8, a constructor object is now returned when window.XMLHttpRequest is called. In JScript, the expression "new window.XMLHttpRequest" instantiates an object from the constructor. However, VBScript has no similar "new" concept, making it incompatible with MDP. Since the object cannot tell when it's being invoked from VBScript, there's no way to revert to the old behavior.
One workaround is to force the page into IE7 Document Compatibility Mode with a META tag:
<meta http-eqiv="X-UA-Compatibile" content="IE=7"/>
This will let you continue to use the XMLHttpRequest object without falling back to an ActiveX component, a scenario which may be required by your IE security settings.
However, to use the highest standards support, you'll need to allow IE to run in IE8 mode and use the ActiveX fallback. One way to detect the browser mode is to use conditional comments to set a global variable.
<!--[if gte IE 8]>
<script type="text/vbscript">
vbIE8 = True
</script><![endif]-->
Then, rewrite your IF statement to look like this:
If Not vbIE8 And IsObject(window.XmlHttpRequest) Then
objXML = window.XmlHttpRequest
Else
...
brian wrote:
Re: Native XmlHttpRequest Support in VBScript
14-Mar-09
Rob
The following page will work in IE7 and fail in IE8
<html xmlns="http://www.w3.org/1999/xhtml"
<head
<title>Test XmlHttpRequest Native Support</title
<script type="text/vbscript"
If IsObject(window.XmlHttpRequest) The
objXML = window.XmlHttpRequest ' use native suppor
MsgBox "Native Support
Els
Set objXML = CreateObject("Microsoft.XMLHTTP") ' go to MSXM
MsgBox "MSXML
End I
objXML.open "GET", "test.xml", Fals
objXML.setRequestHeader "Content-Type", "text/xml
objXML.sen
MsgBox objXML.responseTex
</script
</head
<body
</body
</html
The test.xml can be anything, such as
<?xml version="1.0"?
<test
<text>Display XML Contents</text
</test
If you comment out the If...Then loop, and allow IE8 to use the external
MSXML object, the test succeeds
Brian
++++++++++++++++++++++++++++++++++++++
"rob^_^" wrote:
Previous Posts In This Thread:
On Thursday, March 12, 2009 6:15 AM
brian wrote:
Native XmlHttpRequest Support in VBScript
I have a number of Applications running with VBScript on the client side.
When I test for window.XmlHttpRequest I get a favourable response, but when
it comes time to create the object, as follows
objXMLHTTP = window.XmlHttpReques
the object is not returned, and a string is returned instead. This code
works without problems in IE7
Has the syntax changed for creating the object, or am I missing something
else?
On Thursday, March 12, 2009 6:20 PM
rob^_^ wrote:
Hi Brian,Please always quote your OS version and Service Pack level.
Hi Brian
Please always quote your OS version and Service Pack level
A sample page on a publicly accessible web site would be most helpful
Sample doco - http://msdn.microsoft.com/en-us/magazine/cc301512.asp
Set xmlhttp = CreateObject("Microsoft.XMLHTTP"
xmlhttp.open "GET", "http://expoware/test.asp", Fals
xmltext = "<magazine>MIND</magazine>
Set xmldom = CreateObject("Microsoft.XMLDOM"
xmldom.loadXML xmltex
xmlhttp.send xmldo
MsgBox xmlhttp.responseTex
objXMLHTTP = window.XmlHttpRequest is javascript syntax
Regards
"brianw" <***@discussions.microsoft.com> wrote in message news:0DCD46BB-AF80-4373-BA83-***@microsoft.com...
On Friday, March 13, 2009 1:11 AM
brian wrote:
Rob,Thank you for attempting to answer my query, but you're way off, and your
Rob
Thank you for attempting to answer my query, but you're way off, and your
comments about OS version, SP level and sample pages are made redundant by
the simple fact that my one line of code used to work in IE7
The code you quote creates an external XMLHttpRequest object, using whatever
version of MSXML you currently have installed. You will note from my subject
header that I am specifically interested in native support. And, this is NOT
javascript syntax, it is VBScript syntax. I'm not sure if you noticed, but I
did mention in my question that I have a number of VBScript applications
running, so it's not like I'm all confused about which language I'm using.
This code works in IE7, and also in compatibility mode, by the way:
If IsObject(window.XmlHttpRequest) Then
objXML = window.XmlHttpRequest ' use native support
Else
Set objXML = CreateObject("Microsoft.XMLHTTP") ' go to MSXML
End If
In fact, Rob, this code works in any version of IE, except for IE8. As I
said in my first question, in IE8 the IsObject function returns True, so the
next line of code executes, but when it comes time to use the object, turns
out it's a string!
Anyone else? Does anyone from Microsoft read these discussions?
Brian.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"rob^_^" wrote:
On Friday, March 13, 2009 3:40 AM
rob^_^ wrote:
Hi Brian,Nobody else has taken you on, so this works on Vista SP1 IE8 RC1.<!
Hi Brian,
Nobody else has taken you on, so this works on Vista SP1 IE8 RC1.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/vbscript">
If IsObject(window.XmlHttpRequest) Then
set objXML = window.XmlHttpRequest ' use native support
msgbox "Native Support"
Else
Set objXML = CreateObject("Microsoft.XMLHTTP") ' go to MSXML
msgbox "MSXML"
End If
</script>
</head>
<body>
<button onclick='vbscript:msgbox "IsObject(window.XmlHttpRequest): " &
IsObject(window.XmlHttpRequest) & " IsObject(objXML):" &
IsObject(objXML)'>Test</button>
</body>
</html>
A working test page explains more than a thousand words.
You will find the Microsoft free IE8 phone support numbers on the IE8
Homepage. I will leave it to you to test in IE6 and IE7.
Regards.
"brianw" <***@discussions.microsoft.com> wrote in message news:7ACCB379-0AD4-4BB5-8DA0-***@microsoft.com...
On Friday, March 13, 2009 4:49 AM
brian wrote:
Rob,Now try and do something, anything at all, with the 'object' you created
Rob,
Now try and do something, anything at all, with the 'object' you created in
native support. Something like this:
objXML.open "GET", "test.xml", False
You will get the error: Object required: 'objXML'.
So, my original question remains.
A 'working test page' that doesn't work, or even test anything, is worth,
well, it's worthless.
Brian.
++++++++++++++++++++++++++++++++++++++++++++++
"rob^_^" wrote:
On Friday, March 13, 2009 3:10 PM
rob^_^ wrote:
Hi Brian,So I am not MSFT.
Hi Brian,
So I am not MSFT. I will leave it to you to validate my test page and make
the correction (add form tags).
Regards.
On Friday, March 13, 2009 4:18 PM
brian wrote:
Rob,You still don't understand, your test page cannot be validated or
Rob,
You still don't understand, your test page cannot be validated or corrected,
it's just plain wrong. IE8 does not have native support for XMLHttpRequest
in VBScript, it's broken.
Brian.
"rob^_^" wrote:
On Friday, March 13, 2009 5:34 PM
rob^_^ wrote:
Please provide a publicly accessible test page that demonstrates the issue.
Please provide a publicly accessible test page that demonstrates the issue.
or Copy and Paste your test page markup and script in the thread.
We can raise a ticket for you at connect.microsoft.com.
Regards.
"brianw" <***@discussions.microsoft.com> wrote in message news:CA9531E9-B299-4662-846D-***@microsoft.com...
On Saturday, March 14, 2009 8:50 AM
brian wrote:
Re: Native XmlHttpRequest Support in VBScript
Rob,
The following page will work in IE7 and fail in IE8:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Test XmlHttpRequest Native Support</title>
<script type="text/vbscript">
If IsObject(window.XmlHttpRequest) Then
objXML = window.XmlHttpRequest ' use native support
MsgBox "Native Support"
Else
Set objXML = CreateObject("Microsoft.XMLHTTP") ' go to MSXML
MsgBox "MSXML"
End If
objXML.open "GET", "test.xml", False
objXML.setRequestHeader "Content-Type", "text/xml"
objXML.send
MsgBox objXML.responseText
</script>
</head>
<body>
</body>
</html>
The test.xml can be anything, such as:
<?xml version="1.0"?>
<test>
<text>Display XML Contents</text>
</test>
If you comment out the If...Then loop, and allow IE8 to use the external
MSXML object, the test succeeds.
Brian.
+++++++++++++++++++++++++++++++++++++++
"rob^_^" wrote:
Submitted via EggHeadCafe - Software Developer Portal of Choice
Featured Product / Service Review: TekPub
http://www.eggheadcafe.com/tutorials/aspnet/ae6e21fa-3443-4134-9d2e-39384482c80e/featured-product--servic.aspx