I wrote a library of utility routines in VBScript that can be run on both server and client side via <include>...</include> and <% ... %>. Inside the library, one routine uses XML. I would like a function that would tell me if the routine is running on the server or client so I can create the XMLDOM object properly, something like:
if isServer then
Set objXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
else
set objXMLDoc = CreateObject("Microsoft.XMLDOM")
end if
Is this a reliable way of telling if vbscript is running server- or client-side?
function isServer()
dim result, isServer
result = TypeName(window)
if lcase(result) <> "empty" then
isServer = false
else
isServer = true
end if
end function
I found the following javascript code and converted it to the vbscript above:
function is_server() {
return ! (typeof window != 'undefined' && window.document);
}
However, TypeName in vbscript when I tried returns the string "empty". Wondering if "empty" would be the right string value to check, or if I should check also for "" (empty string) for other IE versions, browsers, etc.
Thanks a lot.