none
IE8 Javascript changes

    Question

  •  

    Does anyone know of a list of the Javascript changes in IE8?  Everything I've found just says its changed.  Also, my site no longer works in IE8, even with compatibility mode turned on.  Any tips on debugging?

     

     

    Thanks!
    -Tina

    Tuesday, December 02, 2008 3:45 PM

All replies

  • Actually a TON of stuff has changed.


    First off, it REALLY matters what mode you are in. In IE8, there are 3 (THREE) modes.

    IE5 Quirks - your page has no doctype, page renders like IE5 did
    IE 7 Standards Mode - you have a doctype, but either opted out of IE8 standards mode, or are running on localhost, or in "Compatibility Mode"
    IE 8 Standards Mode - you have a doctype, and are on the INTRANET (default mode)


    Now, if you are rendering in IE5/IE7 mode, then Nothing changes except that there will be a few methods added that *shouldn't* interfere with your page.


    However, if like the majority, you are running with a doctype set, and thus in IE8 Standards mode, the following changes have occurred.

    1.) document.getElementById( id ); //now only returns the CORRECT matches!
    2.) .getElementsByName( name ); //now only returns the CORRECT matches!
    3.) .getAttribute( name ); //returns the CORRECT value for the given attribute!
    4.) .setAttribute( name, value ); //actually SETS the name/value CORRECTLY (no more cAmElCaSe crud)!
    5.) CSS Expressions are NO LONGER allowed (deprecated)
    6.) Operation Aborted errors will still be thrown (in some cases) however the cases are fewer, and the error won't kill the entire page/DOM
    7.) The attributes[] array on elements should (from the RC build onwards) be correct in terms of contents, have a length, etc.
    8.) Button elements now submit the contents of the value attribute, NOT the HTML contents of the Button Tag


    There has also been a bunch of CSS 2.1 fixes, so things that rendered weird before, or needed hacks, should be much better. (see below for details on alpha/transparency - there's been big changes)

    See the IE Blog for details.

    Also see Web Bug Track for fine grained details on Bugs, Fixes for IE8 (and all other browsers)

    SVG, rounded corners, ECMAScript based Event Listeners, Better Form Element design/events etc. are still missing.

    PS If you have specific issues, let us know and we'll help hunt them down for you. ;-)



    Tuesday, December 02, 2008 7:20 PM
  • Thanks for the information!

     

    My specific issue is that I have an htc control with a bunch of checkboxes on it.  However, when I click a row to check the box, the checkbox on the first row is checked/unchecked.  I'm thinking maybe I'm seeing the change in behavior of .getAttribute causing this.  When you say it now returns the CORRECT value, what did it previously return? 

     

    Also, this is happening even when I have compatibility view turned on. 

     

    Thanks!

    -Tina

    Tuesday, December 02, 2008 9:32 PM
  • IE8 looks like a runt from the start:

     

    1. No-- getElementsByTagname(/DT|DD/i) // using a variant instead of a string like we do split(/<p>|<br>\s*<br>/)

    2. No-- style=border:­parenthetic,hooked,bracket,shy // to replace all that detecting-the-parentheses... 'script-stuff'

    3. No-- regexp skipahead /...(??&\w+;­).../ // 'optional-skip-if-found' like lookbehind but simpler and better than Perl

    4. No-- regexp outlogic (/...(...)...(...).../g,'?1found first?2found second?1?2found both') // to switch-output-on-found

    5. No-- for(i of array) // to get the length and constructor:IE8 attributes/properties, then, for(i in ...) get entries only

    6. No-- if...else...nelse // negative-else-case-logic 'Grand-Then' to simplify repetitious-coded if...||...||... 'script-stuff'

    7. No-- <p:b>...</p> // attribution-by-element/-class generalized combination (compatible with namespace <o:­p>)

    8. No-- auto-/single-command expanded-userdata persistence // for historying-more-than-640KB (e.g. Unicode)

    9. No-- /\s/ finds \240 // find rendered-&nbsp; ('space' the final frontier...!?)

    10. No-- onload,onresize=... // event-compounding e.g. to initialize styles 

    11. No-- clipboardData.getData('HTML'), nor simplified-indentation HTML

    12. And, No-- clipboardData readyState ... It --does-- post old-data...!

     

    Et cetera et cetera et cetera ... I posted MSN 150+ bugs, before MSDN Library 400+, before-- starting here....

     

    Ray.

    Tuesday, December 02, 2008 9:59 PM

  • >> PS If you have specific issues, let us know and we'll help hunt them down for you. ;-)
    What if I see REALLY strange issues, that only happen with IE8, but that don't seem (at least based on all my googling) to happen to anyone  else.  Like for instance, I keep getting strange Javascript errors, and when I use the debugger to see the line they are on, the file it shows me is actually part of one file and the entirety of another file combined.  In other words, I have files A.js and B.js, with the page loading A before B.  I see an error on line 650 of A.js, but A.js only has 550 lines.  When I use the debugger to look at line 650 of "A.js", and then scroll up, I see that the first 100 lines of the file are the first 100 lines of B.js (and, unsurprisingly, having half a file appear as part of another file breaks things).

    Any thoughts on what could be going on?
    Wednesday, April 01, 2009 12:02 AM
  • Of course, ten minutes after I post that I discovered the problem:
        response.setContentType("application/x-javascript;charset=utf-8");
    (in other words, I had the MIME type on the file's header set to "application/javascript", and IE wanted "text/javascript").

    Still, this was INCREDIBLY weird behavior for an incorrect MIME type; in IE9 could you maybe just ignore the MIME type if the file is called *.js, or failing that just refuse to load it entirely?  Doing freaky stuff like combining parts of different files out of order just isn't the right behavior, no matter what MIME type a person uses ...
    Wednesday, April 01, 2009 12:17 AM
  • I know that there are some changes with how Interned Explorer handles JavaScript from version 7 to 8, and I am problems trying to fix a JS menu to look the same in both versions. See www.rgrentals.com to see what I mean. It seems as though IE8 is ignoring the widths for the buttons I have been setting. Any help with this problem?
    Monday, July 20, 2009 4:23 AM
  • I am learning Javascript.  As of right now, what I see there are many "flavors" for Javascript, 1.2 to 2.0.  A lot of 2.0 commands don't seem to work in IE8.  Is there any plan to upgrade IE 8 to Javascript 2.0?

    I downloaded a script, and my particular installation seems to support 1.3.  That's old.
    Friday, February 05, 2010 4:05 PM
  • How can I fix "The remote server machine does not exist or is unavailable" on window.open event ?
    Thursday, May 06, 2010 11:43 AM
  • Have a look a developers checklist by MS: http://www.microsoft.com/windows/internet-explorer/readiness/developers.aspx
    Friday, May 07, 2010 9:03 AM
  • Hi Guys, 

    Developing a web page I found an issue regarding some JS code in IE8. It works in Firefox/chrome/IE7 and IE8 compatibility mode. Do you know what to do in order to support IE8 using following JS?

    Best Regards,

     

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <script type="text/javascript">

            function currencyFormat(fld, milSep, decSep, e) {

                var sep = 0;

                var key = '';

                var i = j = 0;

                var len = len2 = 0;

                var strCheck = '0123456789';

                var aux = aux2 = '';

                var whichCode = (window.Event) ? e.which : e.keyCode;

     

                if (whichCode == 13) return true;  // Enter

                if (whichCode == 8) return true;  // Delete

                key = String.fromCharCode(whichCode);  // Get key value from key code

                if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

                len = fld.value.length;

                for (i = 0; i < len; i++)

                    if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;

                aux = '';

                for (; i < len; i++)

                    if (strCheck.indexOf(fld.value.charAt(i)) != -1) aux += fld.value.charAt(i);

                aux += key;

                len = aux.length;

                if (len == 0) fld.value = '';

                if (len == 1) fld.value = '0' + decSep + '0' + aux;

                if (len == 2) fld.value = '0' + decSep + aux;

                if (len > 2) {

                    aux2 = '';

                    for (j = 0, i = len - 3; i >= 0; i--) {

                        if (j == 3) {

                            aux2 += milSep;

                            j = 0;

                        }

                        aux2 += aux.charAt(i);

                        j++;

                    }

                    fld.value = '';

                    len2 = aux2.length;

                    for (i = len2 - 1; i >= 0; i--)

                        fld.value += aux2.charAt(i);

                    fld.value += decSep + aux.substr(len - 2, len);

                }

                return false;

            }

        </script>

     

    </head>

    <body>

        <form>

        Enter Value:

        <input type="text" name="test" maxlength="15" onkeypress="return(currencyFormat(this,'.',',',event))">

        </form>

    </body>

    </html>


    Thursday, November 25, 2010 3:58 PM
  • Hi,

    Add a DTD (Document type declaration) to your page. Without it MSIE browsers will use Quirks mode.

    Add a return false; to your onkeypress event for the <input> element inside your form block....

    After validate your markup at validator.w3.org (you have errors)

    Use the Developer tool to debug your scripts. F12, Scripts tab, click "Start Debugging"


    Rob^_^
    Thursday, November 25, 2010 7:17 PM
  •  

    Hi, my code is working in IE8(document.getElementById, 'myText'  => mytext). What happened?.

    <script type="text/javascript">
    function teste(){
     var myTextField = document.getElementById('myText');
      alert("Your text: " + myTextField.value)  
    }
    </script>

    <input type="text" id="mytext" />
    <input type="button" onclick="test()" value="test IE8" />

     Thanks,

    Friday, September 16, 2011 3:06 PM
  •   Hi,

      This command is not working in IE8, document.execCommand('italic'). How can I do this? In IE7- works fine.

      Regards,

    Monday, September 19, 2011 1:44 PM
  • var element = document.getElementById( fieldname ); does not work in IE8 on Win7, return null. IE7campatible mode on win7 and IE8 on XP seems ok sometimes.

    I have to fix it by using document.forms[0].fieldname.

    Now I need help on another issue: if fieldname is not a literal string but a variable, how can I get the element?

    Thanks in advance for any help!

    Tuesday, September 27, 2011 10:02 PM
  • I was wrong! document.getElementById(id) does work in IE8.

    Now I found the problem I had. The field ID was not defined but field name only. Once I added ID into input HTML code, it works. The code I tested is really old, not all of the HTML are defined ID, that's why sometimes works sometimes not.

    Hopefully my experience could save other people's time.

    • Proposed as answer by Mansho Friday, September 30, 2011 1:37 PM
    • Unproposed as answer by Mansho Friday, September 30, 2011 1:37 PM
    Wednesday, September 28, 2011 8:34 PM
  •  Hi Jen,

    My question was about-- "document.getElementById( id ); //now only returns the CORRECT matches!" and my example in IE8 work's fine!

    Thank's


     

    Friday, September 30, 2011 1:42 PM