5

Ok peep's so I have this code, but here's a simplified version:

<!DOCTYPE html>
<html>
    <head>
        <title>_</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <script>

            Object.defineProperty(
                Array.prototype,'len',{get:
                    function(){return this.length}
            });

            function pop(){
                ary=['abc',123];
                d1.innerText=ary.len;
            }

        </script>
    </head>
    <body onload="pop()">
        <div id="d1">d1</div>
    </body>
</html>

So my setup is:

  1. Chrome v40.0.2214.94 m
  2. IE v11.0.9600.16428
  3. IIS v7.5.7600.16385

When I open either browser & open the above file as so:

IE ==> C:\site\proj\default.htm
Chrome ==> file:///C:/site/proj/default.htm

Both browsers display the correct result: 2... Yet when I open the file as so:

IE ==> http://portal/proj/default.htm
Chrome ==> http://portal/proj/default.htm

Where portal is the name of the localhost site, setup in IIS.

IE displays undefined and throws a console error of:

Object doesn't support property or method 'defineProperty'

While Chrome still display 2 correctly.


So, I suppose my question is this...

Does IIS change the 'compatibility mode' of IE or something, or do I just need to update to a newer version of IIS?


Thinking Is...

I'm playing round with .hta files for the first time & I was writing an Array.prototype.indexOf property as I got a similar error message as above when trying to access .indexOf on an array...

Thing is, I wanted to make the new indexOf property enumerable, so I used Object.defineProperty to set the property as enumerable, and that's how I ended up on Stack'...

LostInCyberSpace
  • 413
  • 4
  • 19
  • 1
    And did you check IE11 to see if it was in some sort of compatibility mode. Did you add X-UA headers, set to Edge etc ? Are you saying this is in a .hta file? `defineProperty` is defintively supported in IE11, so something else must be going on – adeneo Feb 01 '15 at 10:25
  • 1
    And a quote from MSDN -> *"By default, HTAs display webpages in Compatibility View, which displays standards-mode content in IE7 Standards mode and quirks mode content in IE5 (Quirks) mode. "* – adeneo Feb 01 '15 at 10:27
  • @adeneo: don't know how to check if **IE** is in compat' mode. This is **NOT** a `.hta`, it is `default.htm`. While I'm writing this I've got another 5 tabs open tryin' to learn about the `x-ua-compatible` headder, that I **DON'T** currently have on any my `.hta`'s, & how this runs them in **Quirks mode**? My problem tho, is why the `.htm` file above won't code correctly through **IE** via **IIS**... – LostInCyberSpace Feb 01 '15 at 10:36
  • **Kinda found a better explanation** @ [javascript-version-in-hta?](http://stackoverflow.com/questions/19567887/javascript-version-in-hta?answertab=votes#tab-top) – LostInCyberSpace Feb 01 '15 at 10:49
  • I don't have IIS available, and don't really know anything about IIS, and it's been years since I've played with HTA's. I do however know that setting the correct X-UA header should solve compat issues, and that both `indexOf` and `defineProperty` should be available in IE11 if everything is running correctly – adeneo Feb 01 '15 at 10:50
  • @adeneo: cheers for the help! y'v started me off in the right direction... – LostInCyberSpace Feb 01 '15 at 11:15
  • @adeneo: one last thing dude: Is the header context sensitive? – LostInCyberSpace Feb 01 '15 at 11:33

1 Answers1

0

I think the problem is in IIS, I tested the page in IE11/Win7/NodeJs server and I can see '2'.

etual
  • 561
  • 1
  • 4
  • 13