none
When using an HTA on IE9 the GetObject function is undefined when specifying X-UA-Compatible tag RRS feed

  • Question

  • I'm using Windows 7 with Internet Explorer 9.  I have created a very precise HTA using current HTML standards.  To ensure it renders properly, I specified the X-UA-Compatible meta tag for IE=9 (otherwise the HTA renders in IE7 mode by default).  The tag works perfectly to force the HTA to render modern HTML properly, but this breaks the GetObject function.

    Take this very simple example:

    <html>
    <head>
    	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
    	<title>Test</title>
    	<HTA:Application
    		applicationName = "Test"
    		ID = "html_hta"/>
    </head>
    <body>
    	<script type="text/javascript">
    		var obj = GetObject("WinNT://./administrator");
    		alert("No error if you see this");
    	</script>
    </body>
    </html>

    If you save the example to a file, and run it, you'll get this error:

     

    If you remove the <meta> tag, the HTA works as expected.  I realize that I could simply remove the meta tag to fix the GetObject problem.  However, the HTML wouldn't render as expected - not acceptable at all, actually (IE7 standards mode was really bad).  It would take me hours and hours to find and implement work arounds for all the IE7 quirks.


    Any ideas on how to fix this?  Or, at least, a alternative way in javascript to accomplish what GetObject does?


    -Tony

    Saturday, December 29, 2012 5:36 AM

Answers

  • I posted this question in more appropriate forum.  There are some explanations and suggestions in that thread.

    The "solution" is that IE9+ doesn't support using GetObject() in javascript.  You can still use GetObject() from vbscript, or you can specify <meta http-equiv="X-UA-Compatible" content="IE=8"/> to specify the IE8 engine which still supports GetObject() in javascript.


    -Tony


    • Marked as answer by Tony MCP Sunday, December 30, 2012 9:25 AM
    • Edited by Tony MCP Monday, December 31, 2012 1:26 AM
    Sunday, December 30, 2012 7:25 AM

All replies

  • I've discovered that changing the meta tag to:

    <meta http-equiv="X-UA-Compatible" content="IE=8"/>

    Still allows the GetObject function to work.  The formatting is still not perfect, but it's loads better than IE7 default.

    I'm still hoping for a proper solution.


    -Tony

    Saturday, December 29, 2012 12:27 PM
  • Tony,

    This is the TechNet Forum for questions regarding Internet Explorer 8, 9, 10 for the IT Pro Audience.
    Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions.

    For better assistance please ask for help in the MSDN IE Development Forums.

    Thanks & Regards,

    Vincenzo Di Russo
    Microsoft® MVP Windows Internet Explorer, Windows & Security Expert - since 2003.
    Moderator in the Microsoft Community and TechNet Forums
    My MVP Profile

    Saturday, December 29, 2012 2:32 PM


  • This is the TechNet Forum for questions regarding Internet Explorer 8, 9, 10 for the IT Pro Audience.
    Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions.

    For better assistance please ask for help in the MSDN IE Development Forums.

    Ok, sorry.  Sometimes it's difficult to determine where to post.  How do I delete/close this thread?  I don't want to mark any reply as an answer since it's not been answered.

    Thanks


    -Tony

    Sunday, December 30, 2012 6:27 AM
  • Only a Moderator/Owner can delete this thread.
    No need to mark any reply as an Answer in this thread.

    Best of Luck,

    Vincenzo Di Russo
    Microsoft® MVP Windows Internet Explorer, Windows & Security Expert - since 2003.
    Moderator in the Microsoft Community and TechNet Forums
    My MVP Profile

    Sunday, December 30, 2012 6:41 AM
  • I posted this question in more appropriate forum.  There are some explanations and suggestions in that thread.

    The "solution" is that IE9+ doesn't support using GetObject() in javascript.  You can still use GetObject() from vbscript, or you can specify <meta http-equiv="X-UA-Compatible" content="IE=8"/> to specify the IE8 engine which still supports GetObject() in javascript.


    -Tony


    • Marked as answer by Tony MCP Sunday, December 30, 2012 9:25 AM
    • Edited by Tony MCP Monday, December 31, 2012 1:26 AM
    Sunday, December 30, 2012 7:25 AM
  • Thanks for the update, Tony.

    Regards,

    Vincenzo Di Russo
    Microsoft® MVP Windows Internet Explorer, Windows & Security Expert - since 2003.
    Moderator in the Microsoft Community and TechNet Forums
    My MVP Profile

    Sunday, December 30, 2012 7:31 AM
  • Hi,


    Thanks for sharing. We really appreciate your time and efforts. Hope the answer in that thread will help other community members facing similar problems.


    Thanks,


    Vincent Wang
    TechNet Community Support

    Monday, December 31, 2012 1:17 AM
    Moderator