Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
410 views
in Technique[技术] by (71.8m points)

internet explorer - What are the most likely causes of Javascript errors in IE8?

I'm seeing a lot of Javascript errors in IE8 on pages which worked fine in IE7 (and Firefox, Chrome, and Safari). I know that IE made some changes to things like Javascript security. Some of these don't give clear error messages - things like cross-domain violations can end up throwing very vague exceptions.

Let's make a checklist of top offenders when we're troubleshooting IE8 Javascript errors. Please list one change to the way IE8 Javascript that would cause a Javascript error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I can verify that the ones posted by "unique_username" are accurate!

(quote) 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! nope, not fixed!

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. ;-)

Updates:

window.resize events are currently broken in IE8 Beta2 and IE8 Partner Release 1 (will not fire) now fixed in RTM build

window.open(); in IE8 Partner Release is sometimes failing "claiming" that the target url is not available (quirky, hard to reproduce)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...